This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (shuffle deck) | |
(sort (lambda (x y) (even? (random 2))) deck)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (product . args) | |
(if (null? args) | |
(list '()) | |
(apply append | |
(map (lambda (rest) | |
(map (lambda (first) | |
(cons first rest)) | |
(car args))) | |
(apply product (cdr args)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convert_time(t) { | |
split(t,a,"/"); | |
if (a[3] > 50) { | |
a[3] = sprintf("19%02d", a[3]); | |
} else { | |
a[3] = sprintf("20%02d", a[3]); | |
} | |
month = a[1]; | |
day = a[2]; | |
year = a[3]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Scheme based Domain Specific Language for computing Basal Metabolic Rate | |
; using the Harris-Benedict formula. | |
; https://en.wikipedia.org/wiki/Harris–Benedict_equation | |
"Goal: implement syntax transformers for a program like the following:" | |
'(basal-metabolic-rate | |
(metric | |
(male | |
(weight 90 kg) | |
(height 190 cm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE accounts( | |
id serial PRIMARY KEY, | |
name VARCHAR(256) NOT NULL | |
); | |
CREATE TABLE entries( | |
id serial PRIMARY KEY, | |
description VARCHAR(1024) NOT NULL, | |
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0), | |
-- Every entry is a credit to one account... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var variablep = function(x) { | |
// String is a primitive, so x instanceof String does not do what you think | |
return (typeof x === "string") && (x[0] == "?"); | |
} | |
var equal = function(x,y) { | |
if (x === y) return true; | |
if (x == y) return true; | |
if (typeof x === 'string' && typeof y === 'string' | |
&& x.toLowerCase() == y.toLowerCase()) return true; | |
if (typeof x === 'array' && typeof y === 'array' && x.length == y.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (js-format l) | |
(cond | |
((null? l) "") | |
((not (list? (car l))) (string-append (format #f "'~a'" (car l)) | |
(if (not (null? (cdr l))) | |
(string-append "," (js-format (cdr l))) | |
""))) | |
(else (string-append "\n[" (js-format (car l)) | |
(if (not (null? (cdr l))) | |
(string-append "]," (js-format (cdr l))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wc -l data/* | awk '{if ($1 > 3000) print $1, $2}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
head -1 returns.csv | sed 's/[^,]//g' | wc -c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/37654293/replace-text-in-all-files-within-a-directory-subdirectories-in-emacs/37685982#37685982 | |
I generally do this the way @lawlist suggests. Here it is step-by-step: | |
Install wgrep from Melpa or some other way. I recommend also wgrep-ag and ag if you use The Silver Searcher. | |
Use M-x rgrep (or M-x ag) to search the files and get a list of lines to potentially change. | |
In the *grep* buffer, run M-x wgrep-change-to-wgrep-mode. I bind this to C-x C-q in grep-mode-map. | |
Use query-replace-regexp (C-M-%), or do any other editing in the *grep* buffer. | |
Save the *grep* buffer with C-x C-s. Use C-c C-k to abort. The changes exist only in the *grep* buffer until you save it. You can re-enable wgrep mode any number of times. |