This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[//lasso | |
/* | |
[sys_image] type for Lasso 9.x https://gist.github.com/Ke-/4fc6d3baedc760b076860d96cb102101 | |
This is a replacement for the native [Image] type in Lasso 9.x. This version requires | |
[sys_process] and calls the ImageMagick command line utilities rather than relying on the | |
low-level libraries. Doing so mimises memory use. | |
Based loosely on the Lasso 8.x replacement by Jason Huck https://gist.github.com/jasonhuck/f281afaa528c82a596a9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define tab_to_maps(p::staticarray) => tab_to_map(: #p ) | |
define tab_to_maps(p::string, ...) => { | |
local( | |
delimiter = '\t', | |
lines = params->size > 1 ? params | #p->split('\n'), | |
cols = #lines->first->split(#delimiter), | |
out = array | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define encode_yaml => type { | |
data public d = 0 | |
public oncreate(p::pair, ...) => (with p in params sum .encode(#p) + '\n') | |
public oncreate(p::any) => .encode(#p) | |
public encode(p::map) => { | |
local(out) = array | |
.d++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*///////////////////////////////////////////////////////////////////////////// | |
// | |
// JSON encoder for Lasso 9 (UTF-8) | |
// | |
/////////////////////////////////////////////////////////////////////////////// | |
Skips encoding non-ASCII characters instead relies | |
on requirement specified in the spec. | |
From the spec: http://www.ietf.org/rfc/rfc4627.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////// | |
// | |
// App type loader | |
// | |
///////////////////////////////////////////////////////////////////////// | |
! ::init_thread->istype | |
? define init_thread => thread { | |
public lassoapps => { | |
stdoutnl('init: lassoapps') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thread objects to store data | |
! ::global_store_00->istype ? define global_store_00 => thread {parent map public oncreate => ..oncreate} | |
! ::global_store_01->istype ? define global_store_01 => thread {parent map public oncreate => ..oncreate} | |
! ::global_store_02->istype ? define global_store_02 => thread {parent map public oncreate => ..oncreate} | |
! ::global_store_03->istype ? define global_store_03 => thread {parent map public oncreate => ..oncreate} | |
! ::global_store_04->istype ? define global_store_04 => thread {parent map public oncreate => ..oncreate} | |
// Establish store to use | |
define global_store(name::string) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Base on https://en.wikipedia.org/wiki/List_of_file_signatures | |
define file_signature(filedata::bytes) => { | |
local(hex) = #filedata->sub(1, 32)->encodehex | |
match(true) => { | |
case(#hex->substring(1, 2) == "00") return (: "PIC","PIF","SEA","YTR") | |
case(#hex->substring(12, 16) == "0000000000000000") return (: "PDB") | |
case(#hex->substring(12, 16) == "0000000000000000") return (: "PDB") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var router = (function() { | |
var self = {} | |
var usehistory = window && window.history.pushState ? 1 : 0; | |
self.routes = {} | |
self.go = function(url,title,state){ | |
self.push(url,title,state) | |
self.execute(url) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Local results | |
Random access | |
array((micros = 4593.000000), (micros_average = 459.300000)) - map | |
array((micros = 3266.000000), (micros_average = 326.600000)) - hashtable | |
array((micros = 17445.000000), (micros_average = 1744.500000)) - match | |
"First item" D90CC508-C8B9-46CA-A527-85DE0E4CF387 | |
array((micros = 4785.000000), (micros_average = 4.785000)) - map | |
array((micros = 3977.000000), (micros_average = 3.977000)) - hashtable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?lasso | |
define oauth_consumer_key => 'key' | |
define oauth_consumer_secret => 'secret' | |
define oauth_request_token => 'requestkey' | |
define oauth_request_secret => 'requestsecret' | |
define oauth_access_token => 'accesskey' | |
define oauth_access_secret => 'accesssecret' | |
define oauth_realm => 'http://term.ie/' | |
define oauth_request_endpoint => {return 'http://term.ie/oauth/example/request_token.php'} | |
define oauth_access_endpoint => 'http://term.ie/oauth/example/access_token.php' |
NewerOlder