Skip to content

Instantly share code, notes, and snippets.

View yurrriq's full-sized avatar
🙉
I may be slow to respond.

Eric Bailey yurrriq

🙉
I may be slow to respond.
View GitHub Profile
@yurrriq
yurrriq / stats.sh
Created July 8, 2014 22:49
Read data file and give info using R
#!/bin/bash
R -q -e "x <- read.csv('interesting.data', header = F); summary(x); sd(x[ , 1])"
@yurrriq
yurrriq / ssl.nginxconf
Last active August 29, 2015 14:04
SSL on nginx
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 / {
# ...
@yurrriq
yurrriq / ipconfig.sh
Last active May 14, 2025 06:51
Get Public IP Address in Terminal
#!/bin/bash
# Slow
curl -s ifconfig.me | xargs echo -n
# Faster
curl -s icanhazip.com | xargs echo -n
# API: http://api.ident.me
@yurrriq
yurrriq / watch_yr_bash_bro.sh
Last active August 29, 2015 14:06
Hackish Shellsock Bash Workaround
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
}
@yurrriq
yurrriq / README.md
Last active June 18, 2017 13:25
Oh My Fish! agnoster with a white 𝛌 on a new line at the end of the prompt
@yurrriq
yurrriq / reanimator.sh
Created March 4, 2015 17:03
Revive a Beachballed Menubar
#!/bin/sh
killall -KILL SystemUIServer
@yurrriq
yurrriq / put-many.clj
Created April 6, 2015 19:11
Insert many entities into Datomic at once
(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)))
@yurrriq
yurrriq / empty.clj
Created April 7, 2015 08:07
empty.clj
;; 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
@yurrriq
yurrriq / one_eighteen.clj
Last active August 29, 2015 14:18
4Clojure
(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)
@yurrriq
yurrriq / base64_to_file.clj
Last active August 29, 2015 14:19
Write base64 image data to a file
(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))