JQuery UI accordion is slow in IE 8 - jquery-ui

I have a web application screen with number of dynamically created JQuery UI accordions. I am looping through the incoming JSON string and dynamically create the accordions as follows.
for (i in json.panels) {
var accordionName = json.panels[i].panelName;
var isExpanded = json.panels[i].expand;
var activeProperty = (isExpanded) ? 0 : false;
var accordElemId = "accordion_"+i;
var accordDiv = '<div id="' + accordElemId + '"></div>';
var accordion = $("#"+accordElemId );
var startTime = new Date().getTime();
accordion.accordion({
collapsible: true,
heightStyle: "content",
active: activeProperty,
animated : false
});
var endTime = new Date().getTime();
console.log("Time for "+accordionName+"="+(endTime - startTime));
}
Then i compared the time to create each accordion in IE8 and IE10
in IE8 i found its really slow and when i navigate through pages the performance is continuously degrade.
please have a look at following figures, time is in milliseconds.
1)
LOG: ----------------------------start -------------------------------------
LOG: Time for Patient Address = 16
LOG: Time for Current Legal Status = 32
LOG: Time for Alerts and Risk Factors = 0
LOG: Time for Current Wards/Programs = 16
LOG: Time for Open Orders = 0
LOG: Time for RAI-MH Form = 0
LOG: Time for RAI = 16
LOG: Time for OCAN-C = 31
LOG: Time for LD = 0
LOG: --- Diff create ajaxURL = 0
LOG: ----------------------------end -------------------------------------
2)
LOG: ----------------------------start -------------------------------------
LOG: Time for Patient Address = 16
LOG: Time for Current Legal Status = 47
LOG: Time for Alerts and Risk Factors = 32
LOG: Time for Current Wards/Programs = 16
LOG: Time for Open Orders = 15
LOG: Time for RAI-MH Form = 110
LOG: Time for RAI = 140
LOG: Time for OCAN-C = 141
LOG: Time for LD = 31
LOG: --- Diff create ajaxURL = 0
LOG: ----------------------------end -------------------------------------
3)
LOG: ----------------------------start -------------------------------------
LOG: Time for Patient Address = 62
LOG: Time for Current Legal Status = 485
LOG: Time for Alerts and Risk Factors = 15
LOG: Time for Current Wards/Programs = 219
LOG: Time for Open Orders = 391
LOG: Time for RAI-MH Form = 62
LOG: Time for RAI = 250
LOG: Time for OCAN-C = 391
LOG: Time for LD = 110
LOG: --- Diff create ajaxURL = 0
LOG: ----------------------------end -------------------------------------
Then i tried IE 10 and it super fast and it is consistent with the performance
----------------------------start -------------------------------------
Time for Patient Address = 7
Time for Current Legal Status = 5
Time for Alerts and Risk Factors = 5
Time for Current Wards/Programs = 6
Time for Open Orders = 6
Time for RAI-MH Form = 6
Time for RAI = 4
Time for OCAN-C = 4
Time for LD = 4
--- Diff create ajaxURL = 0
----------------------------end ------------------------------------
Do you guys have any idea about this? appreciate you help
Thanks,
Keth

Related

How to convert a string timestamp into an array in Lua (or other languages)

I'm having this problem for a while and I can't find a good way to resolve it. So I have a timestamp like this for example : local t = "00:00:0.031" and I'm trying to convert it into an array like this :
local ft = {
hours = 0,
minutes = 0,
seconds = 0,
milliseconds = 31
}
This is pretty much the same no matter the language so if you have an idea on how to solve this but don't know Lua you can submit your answer anyway in any language. I tried solving it myself using regex and I'm quite sure it's possible this way...
Thank you for the interest to my question, have a good day (:
You could use string.match to extract the substrings in a first place. In a second time, you could use the function tonumber to convert it into numbers.
function ParseTimestampString (TimestampString)
local Hours, Minutes, Seconds, Milliseconds = string.match(TimestampString, "(%d+)%:(%d+)%:(%d+)%.(%d+)")
local Result
if Hours and Minutes and Seconds and Milliseconds then
Result = {
hours = tonumber(Hours),
minutes = tonumber(Minutes),
seconds = tonumber(Seconds),
milliseconds = tonumber(Milliseconds)
}
end
return Result
end
With the following code, you could get the results you want:
Result = ParseTimestampString("00:00:0.031")
print(Result.hours)
print(Result.minutes)
print(Result.seconds)
print(Result.milliseconds)
This should returns:
> Result = ParseTimestampString("00:00:0.031")
>
> print(Result.hours)
0
> print(Result.minutes)
0
> print(Result.seconds)
0
> print(Result.milliseconds)
31
Here is a not bad way using string.gmatch which is splitting by regex in Lua. Here the value is being split by either ":" or ".". Then there is a counter in place to match the index for the resulting table.
local t = "00:00:0.031"
local ft = {
hours = 0,
minutes = 0,
seconds = 0,
milliseconds = 0
}
local count = 1
for str in string.gmatch(t, "([^:|.]+)") do
ft[count] = tonumber(str)
count = count + 1
end
You can do a printing loop afterwards to check the results
for i = 1, 4 do
print(ft[i])
end
Output:
0
0
0
31
The main problem I have found with my solution is that it does not save the values under the keys listed but instead the numbers 1 2 3 4.
My Simplest Answer Will Be Just Split the given string by your regex, in This Case For HOUR:MIN:SEC.MS
first Split By (:) To Get HOUR MIN & SEC+MS, Then Split SEC+MS by (.) To separate Both seconds And milliseconds
Below is my answer in java
import java.util.*;
class timeX {
long hours = 0,
minutes = 0,
seconds = 0,
milliseconds = 31;
//Convert Given Time String To Vars
timeX(String input) {
//Split Input By (:) For Hour, Minutes & Seconds+Miliseconds
String[] splitted=input.split(":");
this.hours=Long.parseLong(splitted[0]);
this.minutes=Long.parseLong(splitted[1]);
//Split Again For Seconds And Miliseconds By (.)
String[] splittedMandS=splitted[2].split("\\.");
this.seconds=Long.parseLong(splittedMandS[0]);
this.milliseconds=Long.parseLong(splittedMandS[1]);
}
}
public class Main
{
public static void main(String[] args)
{
timeX tmp = new timeX("30:20:2.031");
System.out.println("H: "+tmp.hours+" M: "+tmp.minutes+" S: "+tmp.seconds+" MS: "+tmp.milliseconds);
}
}
With Lua you can do...
The os.date() can be a format tool for seconds.
...but depends on Operating System.
This works on Linux but not (as i know so far) on MS-Windows.
print(os.date('%H:%M:%S',0-3600)) -- puts out: 00:00:00
print(os.date('%H:%M:%S',300-3600)) -- puts out: 00:05:00
Also it can output the date/time as a table.
> tshow=function(tab) for k,v in pairs(tab) do print(k,'=',v) end end
> tshow(os.date('*t'))
day = 4
year = 2021
month = 11
hour = 11
yday = 308
isdst = false
min = 23
wday = 5
sec = 51
...and unfortunally it has no milliseconds.
If the table output of os.date() is saved as a table...
> ttable=os.date('*t')
> os.time(ttable)
1636021672
> os.date(_,os.time(ttable))
Thu Nov 4 11:27:52 2021
> os.date('%H:%M:%S',os.time(ttable))
11:27:52
...then its key/value pairs can be used for: os.time()
Further code do nearly what you expect when in ttable key 1 is your time with milliseconds as a string...
local tshow=function(tab) for k,v in pairs(tab) do print(k,'=',v) end end
local ttable=os.date('*t') -- Create a time table
ttable[1]='0:0:0.31' -- Numbered keys in sequence are ignored by os.tim()
ttable[2]=ttable[1]:gsub('(%d+):(%d+):(%d+)[.](%d+)','return {year=ttable.year,month=ttable.month,day=ttable.day,hour=%1,min=%2,sec=%3,milliseconds=%4}')
-- That creates ttable[2] with the value:
--- return {year=ttable.year,month=ttable.month,day=ttable.day,hour=0,min=0,sec=0,milliseconds=31}
-- Lets convert it now to a table with...
ttable[2]=load(ttable[2])()
-- Using tshow() to look inside
tshow(ttable[2])
That will output...
milliseconds = 31
day = 4
year = 2021
hour = 0
month = 11
min = 0
sec = 0
And this will put it out formated with os.date()
print(os.date('%H:%M:%S.'..ttable[2].milliseconds,os.time(ttable[2])))
-- Output: 00:00:00.31

Awesome WM: Placing tiled clients in specific order on startup

I've installed Awesome WM about a week ago. Since then I've been trying to place terminal clients (bare terminal and vim, vifm, htop) in a specific order on startup. Here is a visual representation of what I'm trying to achieve:
########################
# # htop #
# ###########
# vim # bare #
# ###########
# # vifm #
########################
I've managed to place vim in the right position, but other windows are placed in what seems to be an arbitrary order, which changes with every reboot. Here is the content of my autostart.lua config:
1 local awful = require("awful")
1
2 awful.spawn.single_instance(terminal.."-e xmodmap ~/.Xmodmap; exit")
3 awful.spawn.single_instance("brave-browser", {
4 fullscreen = true,
5 focus = true
6 })
7
8 awful.spawn(terminal.." -e vim", {
9 tag = "edit",
10 placement = awful.placement.left,
11 callback = function(c) awful.client.setmaster(c) end})
12 awful.spawn(terminal.." -e htop", {
13 tag = "edit",
14 height = 80,
15 placement = awful.placement.top_right})
16 awful.spawn(terminal, {
17 tag = "edit",
18 placement = awful.placement.right})
19 awful.spawn(terminal.." -e vifm", {
20 tag = "edit",
21 placement = awful.placement.bottom_right})
22
23 awful.spawn(terminal.." -e neomutt", {
24 tag = "communication",
25 fullscreen = true })
26
27 awful.spawn("Spotify", { tag = "read" })
The layout of the tag with which I have problem is "tile". I'm on Awesome v4.3. What client property should I add to get the desired behavior?
To get clients been spawned in the desired positions on startup callback option should be used. Here is a chunk of my autostart.lua file related to the issue:
1 local awful = require("awful")
1
2 local function spawn_vifm ()
3 awful.spawn(terminal.." -e vifm", {
4 tag = "edit",
5 placement = awful.placement.bottom_right
6 })
7 end
8
9 local function spawn_term ()
10 awful.spawn(terminal, {
11 tag = "edit",
12 placement = awful.placement.right,
13 callback = function(c) spawn_vifm() end
14 })
15 end
16
17 local function spawn_htop ()
18 awful.spawn(terminal.." -e htop", {
19 tag = "edit",
20 placement = awful.placement.top_right,
21 callback = function(c) spawn_term() end
22 })
23 end
.......
38 awful.spawn(terminal.." -e vim", {
39 tag = "edit",
40 placement = awful.placement.left,
41 callback = function(c)
42 awful.client.setmaster(c)
43 store_active_client(awful.tag.find_by_name(awful.screen.focused(), "edit"), c)
44 spawn_htop()
45 end
46 })
Spawning the next client in the callback function of the previous one ensures, that the placement property will be preserved for both of them.
I don't know what you mean by this: "The layout of the tag with which I have problem is tiled left." I assume you mean that your terminals aren't tiling properly? I've used AwesomeWM for about a week a few years ago, but realized quickly it needs a lot of tinkering to get exactly how you want it. What's happening to you is exactly what I was running into.
Found it easier just to use LXDE and Devilspie2. You can Lua script windows to undecorate & maximise, jump to other desktops or whatever you want, fairly easily. This might help get you where you're going, but it's hard to say, without clarification on your question.
local screenwidth = awful.screen.geometry.width
local screenheight = awful.screen.geometry.height
local halfwidth = math.floor( screenwidth /2 )
local thirdheight = math.floor( screenheight /3 )
awful .spawn( terminal .." -e vim", {
tag = "edit",
width = halfwidth,
height = screenheight,
placement = awful .placement .left,
callback = function(c) awful .client .setmaster(c) end } )
awful .spawn( terminal.." -e htop", {
tag = "edit",
width = halfwidth,
height = thirdheight,
placement = awful .placement .top_right } )
awful .spawn( terminal, { -- bare
tag = "edit",
width = halfwidth,
height = thirdheight,
placement = awful .placement .right } )
awful .spawn( terminal .." -e vifm", {
tag = "edit",
width = halfwidth,
height = thirdheight,
placement = awful .placement .bottom_right } )
Also, I'd point out that Conky might be a viable solution, if you're just looking to view terminal output on your desktop, while scripting in Lua.

How to resolve the Flume Syslog set up error - "Event size larger than specified event size: 2500. Consider increasing the max event size"

I am trying to set up Flume syslog source using org.apache.flume.source.MultiportSyslogTCPSource. Set up and configuration successful but I get the following error while flume generates the event from syslog.
[INFO ] [2019-03-28 13:22:27.217] [[channel=file-channel] - CheckpointBackUpThread] [org.apache.flume.channel.file.EventQueueBackingStoreFile] - Checkpoint backup completed.
[WARN ] [2019-03-28 13:22:31.853] [NioProcessor-2]
[org.apache.flume.source.MultiportSyslogTCPSource] - Event size larger than specified event size: 2500. Consider increasing the max event size.
[INFO ] [2019-03-28 13:22:35.686] [SinkRunner-PollingRunner-DefaultSinkProcessor] [org.apache.flume.sink.LoggerSink] - Event: { headers:{flume.syslog.status=Invalid} body: 31 33 33 62 32 20 74 3C 31 33 34 3E 4D 61 72 20 133b2 t<134>Mar }
Here is my configuration looks like:
#source,channel and sink
testagent.sources = testlog
testagent.channels = file-channel
testagent.sinks = logger-sink
#source
testagent.sources.testlog.type = org.apache.flume.source.MultiportSyslogTCPSource
testagent.sources.testlog.ports = 9002
testagent.sources.testlog.host = 127.0.0.1
#sink
testagent.sinks.logger-sink.type = logger
#channel
testagent.channels.file-channel.type = file
testagent.channels.file-channel.dataDirs = /test/data/01/
testagent.channels.file-channel.checkpointDir = /test/data/01/checkpoint
testagent.channels.file-channel.useDualCheckpoints = true
testagent.channels.file-channel.backupCheckpointDir = /test/data/01/checkpoint-backup
testagent.channels.file-channel.transactionCapacity = 10000
testagent.channels.file-channel.checkpointInterval = 20000
testagent.channels.file-channel.maxFileSize = 1072692224
testagent.channels.file-channel.minimumRequiredSpace = 524288000
testagent.channels.file-channel.capacity = 1000000
testagent.channels.file-channel.keep-alive = 3
testagent.channels.file-channel.checkpointOnClose = true
testagent.sinks.logger-sink.channel = file-channel
testagent.sources.testlog.channels = file-channel
Logs generated out of my test application should successfully be displayed into the flume agent log and events should be generated out of each log statement(line).
Update the size of the event in the configuration as shown below:
testagent.sinks.logger-sink.maxBytesToLog = 256
The default size of the event is 16 bytes.

Animate corona SDK enemies

I'm try to create a new game on corona SDK i'm new in lua language, my goal is had a set of enemies in a kind of action game.
For this i think the best way is have a array to store all my enemeis in this case i use three.
So my code is :
local enemies = {}
enemy1 = display.newImageRect( "assets/images/sheep_mini.png", 60, 60 )
enemy1.anchorX = 0
enemy1.anchorY = 0
enemy1.name = 'enemy'
enemy1.id = 1
enemy1.x, enemy1.y = 28, display.contentHeight - 260
enemy1.angularVelocity = 0
enemies[1] =enemy1
enemy2 = display.newImageRect( "assets/images/sheep_mini.png", 60, 60 )
enemy2.anchorX = 0
enemy2.anchorY = 0
enemy1.id = 2
enemy2.name = "enemy"
enemy2.x, enemy2.y = screenW - 120, display.contentHeight - 420
enemy2.angularVelocity = 0
enemies[2] =enemy2
So after that i've a while to iterate to this enemies enemies, but when i try to get the enemies from the array i only getting this :
Mar 31 02:23:36.576: table: 0x600000a66640
Mar 31 02:23:36.577: table: 0x600000a78e00
i'm using this code for doing while :
local len = #enemies
local i= 1
while i <= len do
enemy1 = enemies[i]
print(enemy1)
end
Can you help here? i'm now on corona and also on lua
thanks in advance
What you are trying to achieve can be done through
table.print(enemy1)
For more information I suggest you read this: Table Serialization which explains how:
functions to serialize/unserialize a table or object (usually, not
always, represented as a table), which is to convert it to and from a
string representation. This is typically used for display (e.g.
debugging) or storing data in a file (e.g. persistence).

ruby on rails: need a function to calculate the time and display it in multi language

I need a custom function to calculate the times given from a certain point in the future X
It should countdown from 1 hour to zero
1 hour
59 min
59 min
..
10 min
9 min
..
1 min
59 sec
58 sec
57 sec
..
1 sec
Im currently using the
= clean_text distance_of_time_in_words(Time.now, real_time, true)
With the clean_text function:
def clean_text(string)
bad_words = ["less than", "about"]
change_words = ["hours", "minutes"]
bad_words.each do |bad|
string.gsub!(bad + " ", '')
end
string = string.gsub("hours", "hrs")
string = string.gsub("minutes", "min")
string = string.gsub("minute", "min")
string = string.gsub("half a min", "30 sec")
string = string.gsub("seconds", "sec")
return string
end
But this is insufficient since Im rewriting "minutes" to "min" etc. What would be a good start to write such a custom function for time? I guess it will be quite complex but wondered if there are any rails internal functions I could use?
I need
countdown like listed above
it has to be i18n compatible so I can do 1 hour / 1 houra, etc
Anyone an idea or will it be a custom function thats really neccesairly here?

Resources