I hereby claim:
- I am iamjono on github.
- I am iamjono (https://keybase.io/iamjono) on keybase.
- I have a public key ASBfJQnO3qiS8KTVfZOY5iv1RAh6cI9Ejo8SdkYQQoE_VQo
To claim this, I am signing this object:
| /** | |
| * Flatten | |
| * A function designed to recursively flatten nested array of integers to a single array of integers | |
| * - parameter: a single element of type [Any] | |
| * - returns: an array of integers [Int] | |
| */ | |
| func flatten(_ a: [Any]) -> [Int] { | |
| // Initialize the internal storage array | |
| var container = [Int]() |
I hereby claim:
To claim this, I am signing this object:
| import PerfectLib | |
| import Foundation | |
| import Cocoa | |
| #if os(Linux) | |
| import SwiftGlibc | |
| #else | |
| import Darwin | |
| #endif |
| define numeric_string(in::string) => { | |
| local(out = string) | |
| with char in #in->split('') where string_isNumeric(#char) and #char != '-' && #char != '+' do => { #out->append(#char) } | |
| return #out | |
| } | |
| define numeric_string2(in::string) => { | |
| return string_replaceregexp(#in, -find='\\D', -replace='') | |
| } | |
| numeric_string('123_456-7890') | |
| numeric_string2('(123) 456-7890') |
| /* ============================================ | |
| Lasso 9 port of Bil Corry's lp_string_zap for Lasso 8. | |
| Jonathan Guthrie, Feb 2013 | |
| ============================================ */ | |
| define lp_string_zap(text_to_zap, replacement_text = void, ...) => { | |
| not local_defined('replacement_text') ? local(replacement_text = '') | |
| return string_replaceregexp(#text_to_zap, -find = '[^\\x20-\\x7E\\x09\\x0A\\x0D]', -replace = #replacement_text) | |
| } |
| [ | |
| // ================================== | |
| /* | |
| @author Jonathan Guthrie ([email protected]) | |
| #version 1.00 | |
| This Lasso 9 data type uses the JSON Webservice of http://www.geoplugin.com/ to geolocate IP addresses | |
| See http://www.geoplugin.com/webservices/ for more specific details of this free service | |
| Usage: |
| [ | |
| define gravatar => type { | |
| /* ============================================================== | |
| Retrieves the Gravatar for the given email address. | |
| local(x = gravatar('[email protected]',-default='mm')) | |
| local(x = gravatar('[email protected]',-test=true)) | |
| ============================================================== */ | |
| data | |
| private base = 'http://www.gravatar.com/avatar/', | |
| private securebase = 'https://secure.gravatar.com/avatar/', |
| [ | |
| define human_filesize(size::integer) => { | |
| /* ================================================================= | |
| human_filesize returns a human readable file size from a supplied integer (bytes) | |
| ================================================================= */ | |
| local( | |
| displaysize = string, | |
| calc = decimal, | |
| kb = 1024, | |
| mb = 1024 * #kb, |
| [ | |
| /* ======================================================================================== | |
| wkhtmltopdf | |
| https://code.google.com/p/wkhtmltopdf/ | |
| wkhtmltopdf('http://www.example.com/mypage.lasso?id=83','/pdfcache/id83.pdf',-removelast) | |
| Requires std_shellhandler trait | |
| ======================================================================================== */ | |
| define wkhtmltopdf => type { | |
| trait { |
| /* ============================================================ | |
| See http://rosettacode.org/wiki/Statistics/Normal_distribution#Lasso | |
| ============================================================ */ | |
| define normalDist(mean::decimal=0.5,sdev::decimal=0.2) => { | |
| // Uses Box-Muller transform | |
| return ((-2 * decimal_random->log)->sqrt * (2 * pi * decimal_random)->cos) * #sdev + #mean | |
| } |