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
# From https://askubuntu.com/a/870226 | |
# Tested on Ubuntu 17.04 on 2017-05-15 | |
# To boot Ubuntu Desktop without X one time, add systemd.unit=multi-user.target to the linux command line in GRUB. | |
# To make this the default, use: | |
sudo systemctl set-default multi-user.target | |
# To return to default booting into X, use: | |
sudo systemctl set-default graphical.target |
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
-- see running queries | |
select * from pg_stat_activity; | |
-- Find the process you want to kill, then type: | |
select pg_cancel_backend(<pid of the process>) |
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
-- from Erwin Brandstetter | |
-- http://stackoverflow.com/a/7945274/852196 | |
SELECT reltuples::bigint AS estimate | |
FROM pg_class | |
WHERE oid = 'myschema.mytable'::regclass; |
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
setxkbmap -option ctrl:nocaps |
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
import numpy as np | |
import bokeh.charts as ch | |
from bokeh.plotting import output_notebook, show | |
output_notebook() | |
p = ch.Histogram(data=np.random.uniform(low=0.55, high=0.65, size=1000)) | |
show(p) |
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
;;; collection utilities | |
(defn multi-filter | |
"Perform multiple filter operations in one function call." | |
[fns coll] | |
(reduce (fn [remaining filter-fn] | |
(filter filter-fn remaining)) | |
coll | |
fns)) | |
;;; reflection utilities |
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
(defmacro while-let | |
"While all bindings are truthy, execute body. Useful for draining | |
channels, buffers, anything that can be read, etc." | |
[bindings & body] | |
(let [pairs (partition 2 bindings) | |
test-exprs (map second pairs) | |
test-vals (map first pairs)] | |
`(loop ~bindings | |
(if (and ~@test-vals) | |
(do |
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
### Hey, Alison, here's how you save a ggplot graph in EPS format. | |
# Load the ggplot library | |
library(ggplot2) | |
# Need some data. We'll just make it up for now | |
obs = data.frame( | |
user=factor(c("A", "B", "C", "D")), | |
count=c(1, 2, 3, 4), | |
money=c(0.12, 3.45, 6.78, 9.10)) |