Joda's LocalDateTime(Object, DateTimeZone) doesn't actually force the TimeZone - timezone

I've been looking into using this library and I noticed that the constructor public LocalDateTime(Object instant, DateTimeZone zone) is calling the following line in it's implementation:
iChronology = chronology.withUTC();
This basically resets the zone information and gives you the time for UTC.
Full source code here > http://joda-time.sourceforge.net/apidocs/src-html/org/joda/time/LocalDateTime.html#line.362
Test case
... while printing new object variants to the console, I get the exact same thing
new LocalDateTime(new LocalDateTime(2012, 1, 1, 0, 0), DateTimeZone.getDefault())
Will be printed as
2012-01-01T00:00:00.000
new LocalDateTime(new LocalDateTime(2012, 1, 1, 0, 0), (DateTimeZone) null))
Will be printed as
2012-01-01T00:00:00.000
new LocalDateTime(new LocalDateTime(2012, 1, 1, 0, 0), DateTimeZone.forOffsetHours(8))
Will be printed as
2012-01-01T00:00:00.000
So, what do you think. Is this bugged?
Regards

Related

PHPSpreadsheet: getHighestDataRow/getHighestDataColumn after fromArray

I'm using fromArray to load an array of data into a worksheet. This is working fine. After doing so, getHighestDataColumn and getHighestDataRow do not seem to be updated. Is there a way to force PHPSpreadsheet to recalculate these values after calling fromArray?
[edit] An update seems to have fixed the issue.
Be aware to not use the github#PHPExcel lib if you're still using them.
They've said to update to its directly successor, which is beig maintained and recently updated at github#PhpSpreadsheet
Recently Microsoft released an update which breaks some of the functionalities when we use the old lib.
Getting this example from their doc, you could try using the fromArray():
To set data from an array:
$arrayData = [
[NULL, 2010, 2011, 2012],
['Q1', 12, 15, 21],
['Q2', 56, 73, 86],
['Q3', 52, 61, 69],
['Q4', 30, 32, 0],
];
$sheet->getActiveSheet()
->fromArray(
$arrayData, // The data to set
NULL, // Array values with this value will not be set
'C3' // Top left coordinate of the worksheet range where
// we want to set these values (default is A1)
);
Then you follow this to extract data from the spreadsheet:
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
// Loop for each row
for ($row = 0; $row <= $highestRow; $row++) {
// here you extract the columns for that row
$columns = array_shift(array_values($sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE)));
}

Roblox Lua giving error "TweenInfo.new first argument expects a number for time" even though I am passing in a number

So I am testing an idea to make a script that tweens upon calling a function and passing in items, and I keep getting the error that says "TweenInfo.new first argument excepts a number for time" even though I am passing in a number. Here's my code (also the wait is so it doesn't dissapear before I can see it.:
wait(5)
local TweenPartMove = function(Part, Time, EasingStyle, EasingDirection, TimesToRepeat, IfReverse, DelayPerTween, GoalsXCoords, GoalsYCoords, GoalsZCoords)
local TweeningInfo = TweenInfo.new{
Time,
EasingStyle,
EasingDirection,
TimesToRepeat,
IfReverse,
DelayPerTween
}
local TweenGoals = {
CFrame = Part.CFrame + Vector3.new(GoalsXCoords, GoalsYCoords, GoalsZCoords)
}
TweenService:Create(Part, TweeningInfo, TweenGoals):Play()
end
TweenPartMove(script.Parent, 3, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0, 53, 0, 0)

Ignite ML with multiple preprocessing

Using Ignite machine learning, say I have a labeled dataset like this:
IgniteCache<Integer, LabeledVector<Integer>> contents = ignite.createCache(cacheConfiguration);
contents.put(1, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 705.2, "HD", 29.97, 1, 1, 96.13 }), 2));
contents.put(2, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 871.3, "HD", 30, 1, 1, 95.35 }), 3));
contents.put(3, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 2890.2, "SD", 29.97, 1, 1, 95.65 }), 10));
contents.put(4, new LabeledVector<Integer>(new DenseVector(new Serializable[] { 1032, "SD", 29.97, 1, 1, 96.8 }), 4));
How would I use the NormalizationTrainer on features 0 and 5 but the EncoderTrainer on feature 1? I think I'm having difficulties understanding how to concatenate multiple preprocessing before finally feeding the model trainer.
What I currently have is this (modified Ignite sample):
Vectorizer<Integer, LabeledVector<Integer>, Integer, Integer> vectorizer = new LabeledDummyVectorizer<Integer, Integer>(0, 5);
Preprocessor<Integer, LabeledVector<Integer>> preprocessor1 = new NormalizationTrainer<Integer, LabeledVector<Integer>>().withP(1).fit(ignite, data, vectorizer);
Preprocessor<Integer, LabeledVector<Integer>> preprocessor2 = new EncoderTrainer<Integer, LabeledVector<Integer>>().withEncoderType(EncoderType.STRING_ENCODER).withEncodedFeature(1).fit(ignite, data, preprocessor1);
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
KNNClassificationModel mdl = trainer.fit(ignite, data, preprocessor2);
Do I understand the multiple preprocessor correctly? If so, how would I add another BinarizationTrainer on feature 2? I think I'm getting confused by where to specify which feature to apply the preprocessing trainer on. For one trainer (NormalizationTrainer) I have to use the Vectorizer to tell which features to use, for the EncoderTrainer I can do this as a method function. How would I then add BinarizationTrainer with another Vectorizer?
One preprocessor builds on top of another.
Coordinates are relative to the preprocessor that comes before.
This example shows how to accomplish what you want to do:
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_6_KNN.java
put a breakpoint here: https://github.com/apache/ignite/blob/eabe50d90d5db2d363da36393cd957ff54a18d90/modules/ml/src/main/java/org/apache/ignite/ml/preprocessing/encoding/EncoderTrainer.java#L93
to see how the String Encoder references coordinates
examine all the variables:
UpstreamEntry<K, V> entity = upstream.next(); //this is the row from the file
LabeledVector<Double> row = basePreprocessor.apply(entity.getKey(), entity.getValue()); //after the previous preprocessor has been applied
categoryFrequencies = calculateFrequencies(row, categoryFrequencies); //use the given coordinates to calculate results.
more about preprocessing: https://apacheignite.readme.io/docs/preprocessing
Alternatively, you can use the pipelines API for a more streamlined approach to preprocessing: https://apacheignite.readme.io/docs/pipeline-api

Lua "if...then" statement unresponsive

I'm a newbie using LUA to make missions in
Operation Flashpoint: Dragon Rising's mission editor. I've been trying to get the script down for about a week, I've googled, edited, and scoured the help index of the editor till it feels like my eyes are bleeding and it's all led to this.
I'm having an issue with this "if...then" statement not doing anything. First, here's the whole thing:
function onMissionStart()
OFP:showLetterBoxOsd(false);
OFP:allowPlayerMovement(true);
OFP:allowPlayerFire(true);
OFP:setObjectiveState("Wave1","IN_PROGRESS");
OFP:setObjectiveState("Wave2","IN_PROGRESS");
OFP:activateEntitySet("enemy1");
end --This all seems to work fine, nothing to see here.
--OFP:isAlive(name of unit or entity set)
function isAlive() --After naming this function, a pesky "'<name>' expected near 'if'" error dissapeared so thats nice.
if OFP:isAlive("enemy1") == (false) --This "if..Then" statement should spawn "enemy2" when "enemy1" dies.
then
OFP:activateEntitySet("enemy2");
end
if OFP:isAlive("enemy2") == (false)
then
OFP:setObjectiveState("Wave2","COMPLETED")
OFP:missionCompleted()
end
end
Now here's what's giving me trouble:
function isAlive()
if OFP:isAlive("enemy1") == (false)
then
OFP:activateEntitySet("enemy2");
end
This is supposed to spawn enemy2 when enemy1 dies, but in game it might as well not exist, it doesn't work.
This names my function, the next line was throwing '<name>' expected near if until I did.
function isAlive()
This should track whether enemy1 is still alive, and if it returns a false it should spawn enemy2.
if OFP:isAlive("enemy1") == (false)
then
OFP:activateEntitySet("enemy2");
end
function onMissionStart ist most likely a function the game calls when the mission starts. I could not find any official reference manual but the game seems to have some event based scripting system.
The remaining code you provided probably only executed when the file is loaded and therefor without any effect during the game.
Edit due to comment:
function onMissionStart()
OFP:showLetterBoxOsd(false);
OFP:allowPlayerMovement(true);
OFP:allowPlayerFire(true);
OFP:setObjectiveState("Wave1","IN_PROGRESS");
OFP:setObjectiveState("Wave2","IN_PROGRESS");
OFP:activateEntitySet("enemy1");
end --This all seems to work fine, nothing to see here.
The above code defines the function onMissionStart(). It most likely implements a function that is called by the game, when the mission starts.
You added the following code if I'm not mistaken:
--OFP:isAlive(name of unit or entity set)
function isAlive() --After naming this function, a pesky "'<name>' expected near 'if'" error dissapeared so thats nice.
if OFP:isAlive("enemy1") == (false) --This "if..Then" statement should spawn "enemy2" when "enemy1" dies.
then
OFP:activateEntitySet("enemy2");
end
if OFP:isAlive("enemy2") == (false)
then
OFP:setObjectiveState("Wave2","COMPLETED")
OFP:missionCompleted()
end
end
This also defines a function. isAlive. But who calls that function and when?
I found a list of events in DROPP. I presume that's the mission editor thing you're talking about. On certain events it will run certain functions. Like onAllplayersDead() would be called if all players are dead.
Explaining this all would be beyond the scope of this community. Just read through all of http://www.suderman.com/OFPDR/DROPP/reference.html and all files in http://www.suderman.com/OFPDR/DROPP/download.html
EventScripts = {
onAllPlayersDead = 0,
onArriveAtWaypoint = 0,
onCmdCompleted = 0,
onDeath = 0,
onDespawnEntitySet = 0,
onDespawnEntity = 0,
onDismount = 0,
onEnter = 0,
onEnterRVPoint = 0,
onFirepowerKill = 0,
onHit = 0,
onIdentified = 0,
onIncap = 0,
onLand = 0,
onLeave = 0,
onMissionStart = 0,
onMobilityKill = 0,
onMount = 0,
onMultiplayerMissionLoaded = 0,
onNoAmmo = 0,
onNoAmmoAll = 0,
onObjectDamage = 0,
onObjectDamage = 0,
onObjectiveCompleted = 0,
onObjectiveFailed = 0,
onObjectiveVisible = 0,
onOffboardSupp = 0,
onPinned = 0,
onPlaceableKill = 0,
onPlayEnter = 0,
onPlayDone = 0,
onPlayFailed = 0,
onPlayInvalid = 0,
onPvPMissionEnd = 0,
onRespawn = 0,
onSpawnedReady = 0,
onSpeechEnd = 0,
onSuppressed = 0,
onSuspected = 0,
onUnsuppressed = 0,
}

Grails dropwizard-metrics plugin doesn't output Metrics data in correct format

I was looking for replacement of yammer-metrics plugin for Grails 3.x & found Grails Dropwizard Metrics for the same.
I was trying to integrate it with my sample application(in Grails 3.x) and was following the documentation given at :
http://grails-plugins.github.io/grails-dropwizard-metrics/snapshot/index.html#_healthcheck_beans
Following the blog, I have added below dependencies in build.gradle i.e
compile "org.grails.plugins:dropwizard-metrics:1.0.0.BUILD-SNAPSHOT"
And to test this, I made TestController with index() action i.e
import grails.plugin.dropwizard.metrics.timers.Timed
class TestController {
#Timed('test1')
def index() {
render 'ok'
}
}
With this, running the application and hitting /test/index and then /metrics, No longer returns a valid JSON, containing version, gaugues, counters, timers tag etc. (as seen in http://grails-plugins.github.io/grails-dropwizard-metrics/snapshot/index.html#_exposing_metrics_data)
Instead it just returns JSON in this format:
{
"mem": 830779,
"mem.free": 602088,
"processors": 4,
"instance.uptime": 14766,
"uptime": 30991,
"systemload.average": -1.0,
"heap.committed": 749056,
"heap.init": 786432,
"heap.used": 146967,
"heap": 749056,
"nonheap.committed": 84896,
"nonheap.init": 2496,
"nonheap.used": 81724,
"nonheap": 0,
"threads.peak": 33,
"threads.daemon": 29,
"threads.totalStarted": 37,
"threads": 32,
"classes": 11057,
"classes.loaded": 11057,
"classes.unloaded": 0,
"gc.ps_scavenge.count": 18,
"gc.ps_scavenge.time": 490,
"gc.ps_marksweep.count": 3,
"gc.ps_marksweep.time": 854,
"test1.snapshot.stdDev": 0,
"gauge.response.test.test1": 335.0,
"gauge.response.assets.bootstrap.js": 76.0,
"test1.snapshot.98thPercentile": 31,
"counter.status.200.assets.grails.css": 1,
"gauge.response.assets.jquery-2.2.0.min.js": 146.0,
"test1.snapshot.999thPercentile": 31,
"counter.status.200.test.test1": 1,
"gauge.response.assets.grails-cupsonly-logo-white.svg": 3.0,
"test1.fifteenMinuteRate": 0.2,
"test1.snapshot.min": 31,
"test1.snapshot.95thPercentile": 31,
"test1.meanRate": 0.18974713564659287,
"gauge.response.assets.favicon.ico": 8.0,
"gauge.response.assets.mobile.css": 129.0,
"gauge.response.root": 2301.0,
"counter.status.200.root": 1,
"counter.status.200.assets.jquery-2.2.0.min.js": 1,
"counter.status.200.assets.application.css": 1,
"gauge.response.assets.main.css": 148.0,
"test1.snapshot.mean": 31,
"test1.snapshot.99thPercentile": 31,
"counter.status.200.assets.main.css": 1,
"gauge.response.assets.application.css": 152.0,
"counter.status.200.assets.mobile.css": 1,
"counter.status.200.assets.grails-cupsonly-logo-white.svg": 1,
"test1.snapshot.median": 31,
"gauge.response.assets.grails.css": 145.0,
"counter.status.200.assets.bootstrap.js": 1,
"test1.count": 1,
"test1.oneMinuteRate": 0.2,
"test1.fiveMinuteRate": 0.2,
"test1.snapshot.max": 31,
"test1.snapshot.75thPercentile": 31,
"gauge.response.assets.application.js": 4.0,
"counter.status.200.assets.favicon.ico": 2,
"counter.status.200.assets.application.js": 1,
"gauge.response.assets.bootstrap.css": 249.0,
"counter.status.200.assets.bootstrap.css": 1,
"httpsessions.max": -1,
"httpsessions.active": 0
}
In my sample application, I had tried to register MetricRegistry bean in resources.groovy too like below:
beans = {
metricRegistry(MetricRegistry)
}
But still the output JSON is same.
Please let me what I am missing.
Thanks in advance!

Resources