This file contains 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
<?LassoScript | |
/**! | |
jc_include | |
Includes a file for processing but allows the call to hand over params to the included file. | |
Now also supports including files stored in compiled LassoApps | |
Examples | |
jc_include(file('includetest.inc'), -name = 'brad', -country = 'UK') | |
includetest.inc: |
This file contains 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
/**! | |
export_csv | |
Will export all rows from the given table as a csv file. First row will be the column names. | |
Depends on Ke Carltons DS found here | |
https://github.com/zeroloop/ds | |
Some advantages | |
It does not rely on creating a temporary file on the server. | |
Will send accumulated result to the browser ongoing while looping thru the resultset and thus minimize the memory need on the server. | |
There’s probably no limit on how many records it can export. |
This file contains 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
[ | |
/**! | |
kin_exchangerates | |
Thread object to serve a fairly accurate exchange rate for a given currency | |
To install, go to https://www.openexchangerates.org and sign up for an account. | |
Insert the app_id below and store the thread file where it will be loaded at startup. | |
Attempts to update the rates are limited to no more than once an hour. | |
Call to update rates will be triggered by the first call for a rate. Not when the thread is initialized. |
This file contains 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
#!/usr/bin/lasso9 | |
database_initialize | |
local( | |
date = date, | |
tmp_filef = '//path/to/tmp_files/', | |
stored_filef = '//path/to/stored_files/', | |
path = #stored_filef + #date -> format(`yyyyMMddHHmmss`), | |
movetodir = dir(#path), |
This file contains 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
[ | |
/**! | |
valid_date | |
Replacement of valid_date that adds an optional param -strict. When set to true it will fail on dates that doesn't exist in the real world. Like 2010-02-31. | |
When used with strict assumes that date inputs are either as ISO or US date format. | |
2014-10-13 JC Added to Gist |
This file contains 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
[ | |
/**! | |
client_ip_isin | |
Will return true if client_ip matches any of the strings in the provided staticarray | |
Examples | |
client_ip_isin((: '127.*', '90.229.223.*')) | |
2014-10-08 JC Added to Gist | |
2014-09-10 JC First version |
This file contains 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
[ | |
/* | |
2014-10-08 JC Added to Gist | |
*/ | |
/**! | |
ical_encodebreak | |
Method to ensure that the given string complies to the icalendar requirements that no row inside an icalendar object is longer than 75 octets (bytes) |
This file contains 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 9 | |
Adding an optional param to string -> trim so that it works on any character. | |
Example | |
local(mypath = response_filepath) | |
#mypath -> trim('/') | |
#mypath | |
local(mystring = 'xxxräksmörgåsxx') |
This file contains 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
[ | |
/**! | |
Additions to Lasso 9 dir type that will filter out any invisible files or directories | |
The built in method dir -> eachFilePathRecursive returns all files and directories found | |
in the given path. Using dir -> eachVisibleFilePathRecursive will only return visible files | |
and directories. Very useful if you for example want to get a listing without possible | |
SVN directories in the path. |
This file contains 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
[ | |
/**! | |
encodesql_full | |
Alternative to encode_sql that also deals with escaping % and _ so that the resulting string can be safely used when creating sql queries with LIKE sections. | |
See Bil Corrys talk from LDC Chicago 2008: All Your Base Are Belong To Us | |
Only needed when dealing with SQL queries using LIKE statements (or any of the other pattern- matching queries that recognize “%” and “_”). | |
Example usage | |
var(sql = 'SELECT * |
NewerOlder