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 pop => type { | |
| data | |
| public pop_net = null, | |
| public pop_mode = '', | |
| public pop_timeout = 15, | |
| public pop_token = '', | |
| public pop_index = 0, | |
| public pop_err = 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
| local(data) = bytes('Hello') | |
| my_ds->sql(" | |
| DROP TABLE IF EXISTS bytes_example; | |
| CREATE TABLE bytes_example ( | |
| `data` binary(16) NOT NULL | |
| ); | |
| INSERT INTO bytes_example(data) VALUES (X'" +#data->encodehex + "'); | |
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
| // Cache method result on a thread level | |
| define whatmethod => { | |
| return givenblock->methodname | |
| } | |
| define whattype => { | |
| return givenblock->self->type | |
| } | |
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
| /* | |
| 1: AQ | |
| 62: Pg | |
| 100: Z | |
| 1000: 6AM | |
| 10000: ECc | |
| 100000: oIYB | |
| 1000000: QEIP | |
| 10000000: gJaY | |
| 1000000000: AMqaOw |
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
| // Cache method result on a thread level | |
| define cache_method(c::capture = givenblock) => { | |
| #c->isnota(::capture) ? return #c | |
| local(v) = #c->self ? #c->self->type->asstring + '.' + #c->methodname | #c->methodname | |
| var(#v)->isa(::null) ? var(#v) = #c->detach & invoke | |
| return var(#v) | |
| } |
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 sys_slow_value => 1000.0 | |
| define sys_slow_output(p=null) => { | |
| local(s) = micros | |
| define_atend({ | |
| local(t) = (micros - #s) / 1000.0 | |
| #t > sys_slow_value && web_request ? log_critical('SLOW: ' + client_url + ' — ' + #t + ' milliseconds') | |
| }) | |
| } |
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( | |
| query = .ds->table( | |
| ::mytable | |
| )->select( | |
| #columns | |
| )->where( | |
| #where | |
| )->orderby( | |
| #orderby | |
| )->limit( |
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 sys_info => ( | |
| 'sys_getthreadcount: ' + sys_getthreadcount +'\n' | |
| 'sys_getheapsize: ' + sys_getheapsize +'\n' | |
| 'sys_getheapfreebytes: ' + sys_getheapfreebytes +'\n' | |
| 'sys_getbytessincegc: ' + sys_getbytessincegc +'\n' | |
| 'sys_time: ' + sys_time '\n' | |
| 'sys_getegid: ' + sys_getegid '\n' | |
| 'sys_geteuid: ' + sys_geteuid '\n' | |
| 'sys_getlogin: ' + sys_getlogin '\n' | |
| 'sys_getpid: ' + sys_getpid '\n' |
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 char2int(p::string,mult::integer=1) => { | |
| match(#p) => { | |
| case('a') | |
| return 10 * #mult | |
| case('b') | |
| return 11 * #mult | |
| case('c') | |
| return 12 * #mult | |
| case('d') | |
| return 13 * #mult |
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
| // Inject construct similar to Ruby's inject. | |
| define trait_foreach->inject(p::any) => { | |
| local(gb) = givenblock | |
| #gb->detach | |
| .foreach => { | |
| #p = #gb(#p,#1) || #p | |
| } | |
| return #p | |
| } |