I'm running headless chrome in a lambda layer (https://github.com/alixaxel/chrome-aws-lambda).
Issue is, I am trying to call .toLocaleString("en-AU"), but everything comes out as UTC/GMT regardless. I have read that node didn't always ship with internationalization options. I'm assuming something along those lines is what is going on here.
Any suggestions for how to work around this?
You can use moment.js for better control over time and time formats in NodeJS Lambda
https://momentjs.com/timezone/
var newYork = moment.tz("2014-06-01 12:00", "America/New_York");
var losAngeles = newYork.clone().tz("America/Los_Angeles");
var london = newYork.clone().tz("Europe/London");
newYork.format(); // 2014-06-01T12:00:00-04:00
losAngeles.format(); // 2014-06-01T09:00:00-07:00
london.format(); // 2014-06-01T17:00:00+01:00
Check their announcement about it's future and complications, including internationalization
https://momentjs.com/docs/
Related
I'm trying to setting expire in private Cookie in Rust (Rocket Framework version 0.5.0-rc.1) using rocket::http::Cookie.
In rocket add_private doc I read:
Unless a value is set for the given property, the following defaults are set on cookie before being added to self:
path: "/"
SameSite: Strict
HttpOnly: true
Expires: 1 week from now
I don't understand how to set the Expires property.
I tried to create a new cookie and setting expire using .set_expires() (as in doc example), but it gives me the error: "the trait From<OffsetDateTime> is not implemented for std::option::Option<time::offset_date_time::OffsetDateTime>". The code that return the error is something like (values here only for test purpose):
use rocket::http::{Cookie, CookieJar};
use cookie::time::{Duration, OffsetDateTime};
fn handler(jar: &CookieJar<'_>) {
let mut cookie = Cookie::new("name", "value");
let mut now = OffsetDateTime::now_utc();
now += Duration::days(1);
cookie.set_expires(now);
jar.add_private(cookie);
}
I wonder if I have to use cookie crate instead of rocket::http to create the cookie, but in that case I cannot use CookieJar in the response handler because it expected a rocket::http::Cookie and not a cookie::Cookie.
Is there any other way to set an expire or a max age in private cookie using Rocket http module?
I encountered this same problem and I think I've figured it out:
Rocket uses both the cookie and time packages internally
The example code in the Rocket docs for rocket::http::Cookie actually comes from the cookie package and therefor confusingly uses use cookies::Cookie; instead of use rocket::http::Cookie.
Key thing: The docs at https://api.rocket.rs/v0.5-rc/ appear to be newer that the code that's in crates.io, and use different versions of the cookie and time crates.
So you need to use the same version or cookie or time that Rocket is using. If you're using rocket 0.5.0-rc.1 from crates.io then you need cookie 0.15 or time 0.2.11.
I was able to get my code working with these lines in my Cargo.toml:
rocket = { version = "0.5.0-rc.1", features = ["secrets", "json"] }
time = "0.2.11"
Your example code would then become:
use rocket::http::{Cookie, CookieJar};
use time::{Duration, OffsetDateTime};
fn handler(jar: &CookieJar<'_>) {
let mut cookie = Cookie::new("name", "value");
let mut now = OffsetDateTime::now_utc();
now += Duration::days(1);
cookie.set_expires(now);
jar.add_private(cookie);
}
Alternatively, I think if you use version 0.15 of cookie (you might be using 0.16.0-rc.1) then your code should work as you have it. I think it's cleaner to import Duration and OffsetTime directly from the time package though.
It looks like the latest version of Rocket in Github exposes time as rocket::time so we should be able to switch to that when final 0.5 release comes out.
I wish to load the Vimeo player API asynchronously, using something like:
var tag = document.createElement('script')
tag.src = 'https://player.vimeo.com/api/player.js'
var firstScriptTag = document.getElementsByTagName('script')[0]
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag)
This works fine, though the side effect is that I now need a mechanism to determine when the API has loaded, to initialize a player accordingly. I could use a setInterval() to poll and detect when the Vimeo variable is available I guess, though I was hoping for a more elegant, events based approach, something like:
Vimeo.on('loaded', function(){
new Vimeo.Player('myplayer')
})
Any ideas?
I am working with a CF10 application and trying to define application specific classpaths to load JARs using the this.javaSettings feature introduced in CF10.
From Application.cfc:
THIS.javaSettings = {
LoadPaths = [".\java_lib\",".\java\myjar.jar"],
loadColdFusionClassPath = true,
reloadOnChange = false
}
This is working great, and I can define JARs on an application basis. However, every time I reload the application (for example, if I call applicationStop()) then CF seems to hold on to all the loaded JARs/classes at the same time re-loading them all - which means after a number of reloads I inevitably get an out-of-memory Perm Gen error.
Has anyone experienced this? I have tried the usual things by updating GC strategies to enable permgen collection:
-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
Ok, this was not an issue with the CF feature - turns out that the memory leak was originating in the groovy code that had been compiled in to a jar (you can read groovy details here: https://stackoverflow.com/a/17952925/258813)
It appears as though the CF10 hot-reloading of jars is working ok!
I have a script :
<cfscript>
gf = createObject('component','com.general');
gf.checkIpBlocked();
</cfscript>
that I want to fire onSessionStart.
I added an onSessionStart to /siteID/includes/themes/myTheme/eventHandler.cfc. But the session start NEVER fires. I know there is something managing sessions because of I open the admin, login then close the browser, re-open it I am forced to login again.
If I set a session variable close the browser and and the session.testVar never goes away and seems to hold the initial value for a very long time.
I am not trying to manage mura users or anything I am just trying to set a session variable the first time in a "session". In a typical application.cfc this is easy.
Any insight is appreciated.
Unfortunately, that's a bug. However, one thing to keep in mind is that onSiteSessionStart is unreliable since it only fires when a siteID is defined within the request. For example, if you were to go to the admin and be asked to login your session will have started and there would have been no siteID.
For now I would try using onSiteRequestStart to param the variable instead.
function onSiteRequestStart($){
param name="session.ipChecked" default=false;
if(!session.ipChecked){
var gf = createObject('component','com.general');
gf.checkIpBlocked();
session.ipChecked=true;
}
}
In regard to our documentation we have three Mura 6 books available both printed and digital downloads from Lulu
And are also working to create a systematic way to post the contents of those books on our support site which we are hoping to complete by MuraCon on 9/30. So that the all of our documentation will stay update and in sync.
The Mura docs state that the application events are actually onGlobalSessionStart and/or onSiteSessionStart.
Application Events
onApplicationLoad onSiteSessionStart
onGlobalSessionStart onSiteSessionEnd
onSiteMissingTemplate onSiteError
onGlobalError onBeforeAutoUpdate
onAfterAutoUpdate onGlobalThreatDetect
Note that Events that begin with onGlobal are deļ¬ned on a per-Mura
instance basis.
Mura docs.
My capstone team has decided to use Qooxdoo as the front end for our project. We're developing apps for OpenFlow controllers using NOX, so we're using the NOX webservices framework. I'm having trouble getting data from the service; I know the service is running because if I go to the URL using Firefox the right data shows up. Here's the relevant portion of my code:
var req = new qx.io.remote.Request("http://localhost/ws.v1/hello/world",
"GET", "text/plain");
req.addListener("complete", function(e) {
this.debug(e.getContent());
});
var get = new qx.ui.form.Button("get");
get.addListener("execute", function() {
alert("The button has been pressed");
req.send();
}, this);
form.addButton(get);
In the firebug console I get this message after I click through the alert:
008402 qx.io.remote.Exchange: Unknown status code: 0 (4)
And if I press the Get button again I get this error:
027033 qx.io.remote.transport.XmlHttp[56]: Failed with exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: file:///home/user/qooxdoo-1.0-sdk/framework/source/class/qx/io/remote/transport/XmlHttp.js :: anonymous :: line 279" data: no]
I've also looked at the Twitter Client tutorial, however the "dataChange" event I set up in place of the "tweetsChanged" event never fired. Any help is appreciated, thank you.
This sound like a cross domain request issue. qx.io.remote.Request uses XHR for transporting the data which may not work in every case due to the browser restriction. Switching the crossDomain flag on the request to true will change from XHR to a dynamically inserted script tag doesn't have the cross domain restriction (but other restrictions).
req.setCrossDomain(true);
Maybe that solves your problem.
Additionally, you can take a look at the documentation of the remote package to get some further details on cross domain requests:
http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote
Also take care not to use a request object twice. The only work once.