This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
(new Resource 'Resource.Csvexport)
(context 'Resource.Csvexport)
(define (Resource.Csvexport:Resource.Csvexport)
(catch-all)
)
(define (catch-all action)
(Response:header "Content-Description" "File Transfer")
(Response:header "Content-Type" "text/csv")
(Response:header "Content-Disposition" "attachment; filename=out.csv")
(Response:header "Pragma" "public")
(Response:header "Expires" "0")
(change-dir (append DF_SELF_DIR))
(change-dir "..")
(change-dir "databases")
;; Now we're running sqlite3 binary directly on the server ...
(setq cmd-dump {sqlite3 -header -csv -separator ';' db.sqlite "select * from data;" > out.csv})
(exec cmd-dump)
;; Sending it out ...
(print (read-file "out.csv"))
)
(context MAIN)
(setq textdata "Now think about your brain. It's a long running program running on very complex and error prone hardware. How does your brain keep itself sane over time? The answer may be found in something we spend a third of our lives doing. Sleep.")
(setq text (parse (lower-case textdata) "[^a-z0-9äöüß]+" 0))
(bayes-train text 'DICT)
(bayes-query (parse (lower-case "dsd skjsd ksdjkds sdkj") "[^a-z0-9äöüß]+" 0) 'DICT)
"Now think about your brain. It226128153s a long running program running on very complex and error prone hardware. How does your brain keep itself sane over time? The answer may be found in something we spend a third of our lives doing. Sleep."
("now" "think" "about" "your" "brain" "it" "s" "a" "long" "running" "program" "running"
"on" "very" "complex" "and" "error" "prone" "hardware" "how" "does" "your" "brain"
"keep" "itself" "sane" "over" "time" "the" "answer" "may" "be" "found" "in" "something"
"we" "spend" "a" "third" "of" "our" "lives" "doing" "sleep" "")
(45)
(0.5)
newlisp -m 4096 -s 10000 parse.lsp
newlisp(18433) malloc: *** mmap(size=4258476032) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
ERR: not enough memory in function read-file
(load "stdlib.lql")
(load "dblib.lql")
(timespace "day")
(define string-row *stream*)
(let ((row (reverse
(string-split (str string-row) ":"))))
(if (= (length row) 4)
(begin
(let ((os-ver (nth row 0))
(phone-model (nth row 1))
(error-class (nth row 2)))
(incdb "sessions" 1)
(incdb (session-by "osver" os-ver) 1)
(incdb (session-by "device" phone-model) 1)
(incdb (session-by "error" error-class) 1)
(incdb (session-by-crash "os_ver_class" os-ver error-class) 1)
(incdb (session-by-crash "device_class" phone-model error-class) 1)
(push! (unique "os_ver") os-ver)
(push! (unique "device") phone-model)
(push! (unique "error_class") error-class)))
#f))
A full blown custom LISP language written in C to implement queries, which is many times faster that having a VM (with a garbage collector) online all the timeQuote
#!/usr/bin/env newlisp
;; BEGIN SETTINGS
;; Set Your own Dropbox API keys
;; You can create these keys here: https://www.dropbox.com/developers/apps
(set 'oauth-consumer-key "this-is-your-app-key") ;; this is the App key
(set 'oauth-signature "this-is-so-secret") ;; this is the App secret
(set 'curl "curl") ;; set path to curl executable
;; END SETTINGS
(set 'post-request (append {'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="} oauth-consumer-key {", oauth_signature="} oauth-signature {&"'}))
(set 'post-target "https://api.dropbox.com/1/oauth/request_token")
;; GET TOKEN SECRET
(set 'curlpost (append curl " --silent --header " post-request " " post-target))
(set 'response (first (exec curlpost)))
(set 'oauth_token_secret (first (parse response "&")))
(set 'the-secret (last (parse oauth_token_secret "=")))
(set 'oauth_token (last (parse response "&")))
;; AUTH BY USER
(set 'authurl "https://www.dropbox.com/1/oauth/authorize?")
(set 'callbackurl "&oauth_callback=http://localhost/auth_complete")
(set 'curlauth (append curl " --silent " authurl oauth_token callbackurl))
(exec curlauth)
(println "Opening browser for authorization ... please follow further steps in Your browser.")
(set 'launchcmd (append "open " authurl oauth_token callbackurl))
(exec launchcmd)
(println "When authorization on Dropbox.com was successful press the 'a' key: ")
(while (!= (set 'key (read-key)) 97)
(println "When authorization on Dropbox.com was successful press the 'a' key: ")
)
;; GET ACCESS TOKEN
(set 'access-request (append {'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="4n1wccbr1cyx3la", } oauth_token {", oauth_signature="xppxoa9rpqoviwc&} the-secret {"'}))
(set 'access-target "https://api.dropbox.com/1/oauth/access_token")
(set 'curlaccess (append curl " --silent --header " access-request " " access-target))
(set 'access_response (first (exec curlaccess)))
(println "Access response (JSON): " access_response)
(set 'access_token (parse access_response "&"))
(println "Access token: " access_token)
(set 'oauth_token (last (parse (nth 1 access_token) "=")))
(println "OAuth token: " oauth_token)
(write-file "oauth-token.txt" (string oauth_token))
(set 'access_token_secret (last (parse (first (parse access_response "&")) "=")))
(println "Access token secret: " access_token_secret)
(write-file "token.txt" (string access_token_secret))
(exit)
#!/usr/bin/env newlisp
;; BEGIN SETTINGS
;; Set Your own Dropbox API keys
;; You can create these keys here: https://www.dropbox.com/developers/apps
(set 'oauth-consumer-key "this-is-your-app-key") ;; this is the App key
(set 'oauth-signature "this-is-so-secret") ;; this is the App secret
(set 'curl "curl") ;; set path to curl executable
;; END SETTINGS
(set 'access_token_secret (read-file "token.txt"))
(set 'oauth_token (read-file "oauth-token.txt"))
(set 'header (append {'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="} oauth-consumer-key {", oauth_token="} oauth_token {", oauth_signature="} oauth-signature {&} access_token_secret {"'}))
(define (json2list response)
(json-parse (first response))
)
(define (accountinfo)
(set 'endpoint "https://api.dropbox.com/1/account/info")
(set 'url (append curl " --silent --header " header " " endpoint))
(set 'response (exec url))
(json2list response)
)
(println (accountinfo))
(exit)
(set 'jsdata (get-url "http://j.maxmind.com/app/geoip.js"))
(set 'location (find-all [text]'(.*)'[/text] jsdata))
(print location)
#!/usr/bin/env newlisp
;; SET IP and PORT
(set 'ip "127.0.0.2")
(set 'port 8080)
;; BUILD UP SOCKET
(set 'connection (net-listen port ip "multi"))
(if connection
(println "LispIO webserver started on " ip ":" port)
(println (net-error))
)
;; ENTER LOOP
(while (not (net-error))
(set 'msg (net-receive-from connection 1024))
;(println "->" msg)
(set 'response [text]
"HTTP/1.0 200 OKrn"
"Server: LispIOrn"
"Content-Type: text/htmlrn"
"rn"
[/text]
)
(net-send-to (nth 1 msg) (nth 2 msg) response connection)
(println "Hello World")
)
(exit)
#!/usr/bin/newlisp
(set 'socket (net-listen 8081 "" "multi"))
(if (not socket) (println (net-error)))
(while (not (net-error))
(print "Enter something -> ")
(net-send-to "localhost" 8080 (read-line) socket)
(net-receive socket buff 255)
(println "=> " buff)
)
Enter something -> hello
=>
"HTTP/1.0 200 OKrn"
"Server: LispIOrn"
"Content-Type: text/htmlrn"
"rn"
(amazon:list-all-buckets 1000)
ERR: server code 400: HTTP/1.1 400 Bad Request
<Error><Code>InvalidArgument</Code><Message>AWS authorization header is invalid. Expected AwsAccessKeyId:signature</Message>
#!/bin/bash
# Simple bash script for installing newLISP on Amazon EC2, Ubuntu 12.04 AMI
# Author: Marc Hildmann, July 2012
#
read -p "Install necessary default building libraries (y/n)?" CONT
if [ "$CONT" == "y" ]; then
sudo apt-get install libffi-dev build-essential libreadline-dev
else
echo "No libraries were installed.";
fi
read -p "Now changing to /tmp and download newLISP (y/n)?" CONT
if [ "$CONT" == "y" ]; then
cd /tmp
wget http://www.newlisp.org/downloads/newlisp-10.4.3.tgz
tar xvfz newlisp-10.4.3.tgz
cd newlisp-10.4.3
else
echo "Nothing happened.";
fi
read -p "Build and install newLISP (y/n)?" CONT
if [ "$CONT" == "y" ]; then
make
sudo make install
echo "### Installation finished ###"
else
echo "Nothing happened.";
fi
(new Tree 'products)
(define (highest-key tree)
(if-not (empty? (tree))
(begin
(println "Tree is not empty.")
(string (inc (integer (first (last (sort (tree)) <)))))
)
(begin
(println "Tree is empty.")
(string (integer 1))
)
)
)
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products)
(("1" "hello") ("10" "hello") ("2" "hello") ("3" "hello") ("4" "hello") ("5" "hello")
("6" "hello")
("7" "hello")
("8" "hello")
("9" "hello"))