Skip to content

Instantly share code, notes, and snippets.

View Ke-'s full-sized avatar

Ke Ke-

  • Zeroloop Limited
  • New Zealand
View GitHub Profile
@Ke-
Ke- / ds_cart.lasso
Last active December 30, 2015 05:49
Public DS Cart
define cart_id => var(cart_id) || $cart_id := lasso_uniqueid
define current_cart => var(current_cart) || $current_cart := cart->oncreate('id' = cart_id)
define cart => type {
parent activerow
public ds => ds(::example.carts)
public created_column => 'created'
public modified_column => 'modified'
@Ke-
Ke- / set_user_password.lasso
Last active December 27, 2015 04:19
Set a Lasso user's password
define set_user_password(user::string,password::string) => {
#password = security_registry->encodePassword('Lasso Security',#user,#password)
inline(
-database = 'security_auth_registry',
-sql = 'UPDATE users SET password_ha1 = "'+#password->encodesql+'"
WHERE name = "'+#user->encodesql+ '" '
) => {}
}
// Usage:
@Ke-
Ke- / keycolumn.lasso
Last active December 27, 2015 02:19
keycolumn_value
protect => {inline}
define keycolumn_value() => {
local(c = column(keycolumn_name))
void != #c? return #c
local(curMap = inline_scopeGet)
#curMap && #curMap->size > 0 ? #c = #curMap->find(::currentinline)->dsInfo->forcedRowID
#c->isa(::integer) && #c < 0 ? #c = 2147483648 + (2147483648 + #c)
@Ke-
Ke- / every.lasso
Last active December 25, 2015 20:19
Useful for gaining control of active_tick within threads.
<?lassoscript
/*
Description:
Restricts code from executing more frequently than the specified number of seconds.
Returns the number of seconds to wait until blocks should be executed.
Example:
define my_thread => thread {