Skip to content

Instantly share code, notes, and snippets.

Avatar

Jolle Carlestam jolle-c

  • Kulturfaktorn
  • Lund, Sweden
View GitHub Profile
@jolle-c
jolle-c / hash_sha512.lasso
Last active Mar 13, 2019
Returns a hashed string using SHA512 for hashing
View hash_sha512.lasso
[
/**!----------------------------------------------------------------------------
hash_sha512.lasso
Author: Jolle Carlestam
License: Public Domain
Description:
For when you want a hashed string using SHA512 for hashing.
Requires the Lasso 9 version of shell
@jolle-c
jolle-c / kin_slugify.lasso
Last active Sep 26, 2018
For when you want a string, like a headline for a news article, to be used as part of a URL
View kin_slugify.lasso
[
/*----------------------------------------------------------------------------
kin_slugify.lasso
Author: Jolle Carlestam
License: Public Domain
Description:
For when you want a string, like a headline for a news article, to be used as part of a URL. Safe to send out in the wild.
@jolle-c
jolle-c / safe_filename.lasso
Created Nov 10, 2017
safe_filename will take a string as input and return a string safe to use as a file name
View safe_filename.lasso
define safe_filename(
filename::string,
-replacechar::string = '-',
-clearemoji::boolean = false,
-noleadingperiod::boolean = false,
-allowed_length::integer = 255
) => {
local(_filename = string(#filename))
@jolle-c
jolle-c / jwt.lasso
Created Apr 25, 2017
JSON Web Token (JWT) type for Lasso 9
View jwt.lasso
[
/**!
jwt
Lasso 9 type to sign, encode and verify JSON Web Tokens (JWT).
Requires a version of Lasso that supports json_encode and json_decode.
Developed and tested on Lasso 9.3.
Inspired by methods published by Alex Betz on Lasso Talk in April 2017
2017-04-25 JC First version
@jolle-c
jolle-c / shell.lasso
Last active Mar 13, 2019
Wrapper for sys_process
View shell.lasso
[
/**!----------------------------------------------------------------------------
shell.lasso
Adaptation of Jason Huck's Shell tag for Lasso 8.5
Author: Jonathan Guthrie, Jolle Carlestam
Last Modified: 2018-03-20
License: Public Domain
@jolle-c
jolle-c / array -> encodesql
Created Mar 1, 2017
Will make sql injection safe string of each item in an array
View array -> encodesql
/**!
array -> encodesql
Adds a method to the lasso 9 array and staticarray types that will run encodesql on each item in the array.
This changes the array in place.
It also alters each item to type string.
EXAMPLE USAGE
local(ids = array('1', '5', '22'))
local(sql = "SELECT * FROM mytable AS mt
@jolle-c
jolle-c / client_ip_isin.lasso
Created Feb 3, 2016
Lasso 9 method to check if a range of IP numbers match the current client ip
View client_ip_isin.lasso
/**!
client_ip_isin
Will return true if client_ip matches any of the strings in the provided staticarray
Examples
client_ip_isin((: '127.*', '94.219.224.*'))
2014-09-10 JC First version
*/
View export_csv.lasso
/**!
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.
@jolle-c
jolle-c / kin_exchangerates.lasso
Created Mar 27, 2015
Thread object to serve a fairly accurate exchange rate for a given currency
View kin_exchangerates.lasso
[
/**!
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.
View jc_include.lasso
<?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:
You can’t perform that action at this time.