How read file real time for chat application? - rebol

I'm trying to write a simple chat application in Rebol which is based on a single text file.
What would be the best way to read that file "real time"?
Right now I've got it working with this:
t1: text 600x300 wrap green black font-name font-fixed rate 1 feel[
engage: func [face action event][
if action = 'time [
face/text: read chatText
show face
]
]
]
The text field gets updated every second with the content of the file. That works, even with multiple users, but the whole file is read every second for every user.
Is there a better way to do this kind of thing?

Have a look on info? function.
You can do something like this:
REBOL []
chat-file: %file.txt
file-info: info? chat-file
update-date: file-info/date
view layout [
t1: text read chat-file 600x300 wrap green black font-name font-fixed rate 1 feel [
engage: func [face action event] [
if all [
action = 'time
file-info: info? chat-file
update-date < file-info/date
] [
update-date: file-info/date
face/text: read chat-file
show face
]
]
]
]
But you need to be careful if you will write to the file from multiple apps.

Related

Apply multiple format rules to a single rjsf field

I like the rjsf format api, it works great for me:
"format": "alphanumeric"
But I would like to assign multiple format rules to a single field, and use transformErrors api to display a different message for each, giving user more precise feedback about what's wrong. Something along the lines of:
"format": ["alphanumeric", "mustBeginWithLetter"]
but this array notation doesn't work and breaks the formatting instead :)
Is there a clean way to achieve what I want?
"allOf": [ {"format": "alphanumeric"}, {"format": "mustBeginWithLetter"} ]

JSON-LD schema won't validate in SDTT

I've spent hours on this without solution. I'm having a terrible time identifying and correcting an error when validating in Google SDTT. After dozens of revisions, I continue to get "Missing ',' or ']' in array declaration" error. I'd appreciate if someone will take a look, make the needed corrections or show me what I'm overlooking. Here's the code snippet >> https://drive.google.com/drive/folders/1HNJgZrGa7_F6-7FuGCbL2Y0vFPGsX7MQ
Your top sameAs is a bit mixed up. I suspect you wanted to quote every URL and drop the last comma. e.g.
"sameAs" : [ "https://plus.google.com/100804793716209856515", "https://plus.google.com/115455274861158767219", "https://www.facebook.com/pg/TallentRoofingInc/about/", "https://www.yelp.com/biz/tallent-roofing-mckinney-2", "https://www.yelp.com/biz/tallent-roofing-melissa", "https://www.yelp.com/biz/tallent-roofing-el-paso-2", "https://www.yelp.com/biz/tallent-roofing-alpine", "https://www.yelp.com/biz/tallent-roofing-artesia" ]
Your graph is an array, but does to some bad closing of }s so it directly includes properties. Remove the } on the line before "aggregateRating" and add one to the line after "reviewCount".
,
"aggregateRating" :
{
"#type": "AggregateRating",
"ratingValue" : "4.9",
"ratingCount": "57",
"reviewCount": "53"
}},

PostgreSQL: Create Index in JSON Array

I am pretty new to postregSQL and not too familiar with SQL yet. But im trying to learn.
In my database i want to store huge JSON files (~2mio lines, 40mb) and later query them as fast as possible. Right now it is to slow, so i figured indexing should do the trick.
The Problem is i do not know how to index the file since it is a bit tricky. I am woking on it the whole day now and starting to get desperate..
My DB is calles "replays" the json column "replay_files"
So my files look like this:
"replay": [
{
"data": {
"posX": 182,
"posY": 176,
"hero_name": "CDOTA_Unit_Hero_EarthSpirit"
},
"tick": 2252,
"type": "entity"
},
{
"data": {
"posX": 123,
"posY": 186,
"hero_name": "CDOTA_Unit_Hero_Puck"
},
"tick": 2252,
"type": "entity"
}, ...alot more lines... ]}
I tried to get all the entries with say heron_name: Puck
So i tried this:
SELECT * FROM replays r, json_array_elements(r.replay_file#>'{replay}') obj WHERE obj->'data'->>'hero_name' = 'CDOTA_Unit_Hero_Puck';
Which is working but for smaller files.
So i want to index like that:
CREATE INDEX hero_name_index ON
replays ((json_array_elements(r.replay_file#>'{replay}')->'data'->'hero_name);
BUt it doesn work. I have no idea how to reach that deep into the file and get to index this stuff.
I hope you understand my problem since my english isnt the best and can help me out here. I just dont know what else to try out.
Kind regards and thanks alot in advance
Peter

simplecart js setting column widths

I've used this site for assistance many times but never had to ask a question so finally joined...anyway, trying to set up simplecart checkout and having some trouble formatting cart output. I have my cart set to table and by default the simpleCart_items class displays the table and it's cells only as wide as they need be to fit the data. I can change this by specifying all cells(columns) as a percentage of the whole table. Unfortunately with 7 columns each only gets about 14% and this is way to much for a 1 or 2 digit quantity and not near big enough for all the characters in the item name without wrapping. What I want is a way to define a different width for each column. I have not found a way to do this even with colgroup but maybe just not doing it right. Any and all help would be appreciated!
Okay, so this may or may not help. This line is located in the simpleCart.js file. I changed it to something simple.
cartColumns : [
{ view: function(item, column){
return"<img src='"+item.get('image')+"' width='250px' height='250px'><br /><center><h3 ><span>"+item.get('name')+"</span></h3><p><a href='javascript:;' class='simpleCart_decrement'><button>-</button></a> "+item.get('quantity')+" <a href='javascript:;' class='simpleCart_increment'><button>+</button></a></p><p>$"+item.get('price')+"</p><p><a href='javascript:;' class='simpleCart_remove remove_icon'><img src='images/icon_x.png' /></a></p></center>";
},
}
],
You can change it to your own html
cartColumns : [
{ view: function(item, column){
return" YOUR HTML HERE ";
},
}
],
It MUST all be in ONE (1) LINE or else it may not work.
here are some values that are used
image = item.get('image')
name = item.get('name')
quantity = item.get('quantity')
price = item.get('price')
you can look at all the values here
http://simplecartjs.org/documentation/displaying_cart_data
but the point is that you can make a cart and display it how you want; with you own html and css. I hope this helped.

Azure HBASE REST - simple get failing for colfam:col

This should be a very simple one (been searching for a solution all day - read a thousand and a half posts).
I put a test row in my HBASE table in hbase shell:
put 'iEngine','testrow','SVA:SourceName','Journal of Fun'
I can get the value for a column family using the REST API in DHC Chrome:
https://ienginemaster.azurehdinsight.net/hbaserest/iEngine/testrow/SVA
I can't seem to get it for the specific cell: https://ienginemaster.azurehdinsight.net/hbaserest/iEngine/testrow/SVA:SourceName
{
"Row": [{
"key": "dGVzdHJvdw==",
"Cell": [{
"column": "U1ZBOlNvdXJjZU5hbWU=",
"timestamp": 1440602453975,
"$": "Sm91cm5hbCBvZiBGdW4="
}]
}]
}
I get back a 400 error.
When successfully asking for just the family, I get back:
I tried replacing the encoded value for SVA:SourceName, and a thousand other things. I'm assuming I'm missing something simple.
Also, the following works:
hbase(main):012:0> get 'iEngine', 'testrow', 'SVA:SourceName'
COLUMN CELL
SVA:SourceName timestamp=1440602453975, value=Journal of Fun
1 row(s) in 0.0120 seconds
hbase(main):013:0>
I opened a case with Microsoft support. I received confirmation that it is a bug (IIS and the colon separator not working). They are working on a fix - they are slightly delayed as the decide on the "best" way to fix it.