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
#!/bin/bash | |
R -q -e "x <- read.csv('interesting.data', header = F); summary(x); sd(x[ , 1])" |
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
server { | |
listen 443; | |
ssl on; | |
ssl_certificate /path/to/ssl.crt; | |
ssl_certificate_key /path/to/ssl.key; | |
root /path/to/web/root; | |
server_name server.name; | |
location / { | |
# ... |
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
#!/bin/bash | |
# Slow | |
curl -s ifconfig.me | xargs echo -n | |
# Faster | |
curl -s icanhazip.com | xargs echo -n | |
# API: http://api.ident.me |
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 fix_it { | |
for i in $(seq 8); do echo; done | |
cd ~ && mkdir bash-fix && cd $_ | |
curl https://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz | tar zxf - | |
cd bash-4.3 | |
for i in $(seq -f "%03g" 1 25); do | |
curl -s https://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i | patch -p0 | |
done | |
./configure && make && make install && bash --version && rm -r bash-4.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
#!/bin/sh | |
killall -KILL SystemUIServer |
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
(require '[datomic.api :as d]) | |
(let [uri "datomic:dev://localhost:4334/example" | |
coll (map (fn [k v] {k v}) | |
(map (comp keyword str char) (range 97 123)) | |
(iterate inc 0)) | |
conn (d/connect uri)] | |
(->> (map (fn [m] (assoc m :db/id (d/tempid :db.part/user))) coll) | |
(d/transact conn))) |
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
;; I forget about this function too often, so now it's a gist! | |
(empty '(1 2 3)) ; <= () | |
(type *1) ; <= clojure.lang.PersistentList$EmptyList | |
(empty (range 1 3)) ; <= () | |
(type *1) ; <= clojure.lang.PersistentList$EmptyList | |
(empty [1 2 3]) ; <= [] | |
(type *1) ; <= clojure.lang.PersistentVector |
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
(ns me.ericb.fourclojure.one-eighteen) | |
(defn map' | |
"Given a function f and an input sequence s, | |
return a lazy sequence of (f x) for each element x in s." | |
{:see-also [["http://www.4clojure.com/problem/118" | |
"118. Re-implement Map"]]} | |
[f s] | |
(lazy-seq | |
(when (seq s) |
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
(refer-clojure :exclude [replace]) | |
(require '[clojure.java.io :refer [output-stream]] | |
'[clojure.string :refer [replace]]) | |
(import '(org.apache.commons.codec.binary Base64)) | |
(let [src "data:image/png;base64,..." | |
data (Base64/decodeBase64 (replace src #"^data:image/\w+;base64," "")) | |
out (output-stream "/path/to/file.png")] | |
(.write out data)) |