Skip to content

Instantly share code, notes, and snippets.

(=> for i in [1, 2, 4]
alert( i ))()
alert( i )
#+NAME: json-document-example
#+BEGIN_SRC emacs-lisp :exports results :results table
(setq *json-doc-uri*
"https://raw.githubusercontent.com/alicemaz/corpora/master/data/foods/beer_styles.json")
(defun get-json-document (uri)
(with-current-buffer
(url-retrieve-synchronously uri)
(goto-char (+ 1 url-http-end-of-headers))
flags: {}
packages:
- '.'
extra-deps: []
resolver: nightly-2015-10-15
@larsen
larsen / pythTriples.hs
Last active October 22, 2015 10:11
the lower bound of smartness :-)
perfectSquares = map (^2) [1..1000]
solution = [ (x, y, z)
| z <- perfectSquares,
x <- perfectSquares,
y <- perfectSquares,
x < z, y < x,
x + y == z ]
longestPrefix :: [Char] -> [Char] -> [Char]
longestPrefix [] _ = []
longestPrefix _ [] = []
longestPrefix (a:as) (b:bs)
| a == b = [a] ++ longestPrefix as bs
| otherwise = []
;; Context:
;; I have a org-mode file containing my books collection, with
;; some metadata attached. I wrote some functions to manipulate
;; those data.
;; In order to be able to evaluate these functions not only in
;; the context of that file buffer, I wrote the macro `with-book-collection`
(defun books/pages-read-in-2015 ()
(reduce '+ (mapcar (lambda (b) (string-to-int (cdr (assoc "Pages" b))))
(books/in-year "2015"))))
;; *** STARTED The Atrocity Archives, Charles Stross :fiction:computerscience:sf:
;; - State "STARTED" from "QUEUE" <2015-03-27 Fri 10:19>
;; :PROPERTIES:
;; :Title: The Atrocity Archives
;; :Author: Charles Stross
;; :Pages: 295
;; :Language: English
;; :Cover: file:books-covers/TAA-cover.jpg
;; :Comment:
;; :END:
{
"question" : {
"left" : {
"artist_id" : "106",
"metadata" : {
"oa_artist_info" : {
"cover_photo" : [
{
#!/bin/sh
# Setup some variables needed for bootstrapping the environment
ROOT=/home/vrde/projectz/myproject
REPOS=${ROOT}/repos
export PYTHONPATH=${REPOS}
@larsen
larsen / datetime-iterator.pl
Created October 16, 2013 09:49
DateTime iterator over a dates span
my $from;
if ($opt->get_from) {
$from = $strp->parse_datetime($opt->get_from);
}
elsif ($opt->get_yesterday) {
$from = DateTime->now->add( days => -1 );
}
my $today = DateTime->now;