Skip to content

Instantly share code, notes, and snippets.

Jarrell Waggoner malloc47

Block or report user

Report or block malloc47

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@malloc47
malloc47 / oneline.tex
Last active Dec 15, 2015
Example of LaTeX snippet that keeps text on a single line, but resizes it to fit the width, if it would otherwise wrap.
View oneline.tex
\documentclass{article}
\usepackage{xifthen}
\usepackage{graphicx}
 
\newcommand{\oneline}[1]{%
\newdimen{\namewidth}%
\setlength{\namewidth}{\widthof{#1}}%
\ifthenelse{\lengthtest{\namewidth < \textwidth}}%
{#1}% do nothing if shorter than text width
{\resizebox{\textwidth}{!}{#1}}% scale down
View bit.clj
(ns bit)
(defn printb
[n]
(Integer/toBinaryString n))
(defn count-1s
[n]
(->> n printb (filter #{\1}) count))
View matrix.clj
(ns matrix)
(defn mget
[m i j]
(-> m (nth j) (nth i)))
(defn mset
[m i j v]
(assert (and (< j (count m))
(< i (count (first m)))))
View sequence.clj
(defn happy-next
[n]
(let [digits (->> n str seq (map #(Character/digit % 10)))]
(->> (map * digits digits)
(apply +))))
(defn happy'
[n seen]
(loop [n n seen seen]
(cond
View bootstrap-ubuntu.sh
sudo apt-get install emacs
# caps -> ctrl
setxkbmap -layout us -option ctrl:nocaps
# or
sudo apt-get install gnome-tweak-tool
gnome-tweak-tool
# disable super key
xmodmap -e 'keycode 133 = NoSymbol'
xmodmap -e 'keycode 134 = NoSymbol'
# change setting
View numpy_to_latex.py
def to_latex(a,label='A \\oplus B'):
sys.stdout.write('\[ '
+ label
+ ' = \\left| \\begin{array}{'
+ ('c'*a.shape[1])
+ '}\n' )
for r in a:
sys.stdout.write(str(r[0]))
for c in r[1:]:
sys.stdout.write(' & '+str(c))
@malloc47
malloc47 / README.md
Last active Dec 3, 2017
OS X Sierra Keybindings Per Application Using Hammerspoon
View README.md

OS X Sierra + VirtualBox + Hammerspoon

I prefer different modifier keybindings for my VM vs. native OS X, but VirtualBox (unlike VMWare/Parallels) passes the keyboard through to the VM natively without the ability to remap it on the way through.

Apparently one would normally use Karabiner to do all manner of trickery to remap keys per application etc. but support for this utility was broken in OS X Sierra. Instead, I use a pair of scripts:

View cloudera-hosts.sh
#!/bin/bash
read -p "environment: " env
read -p "user: " user
read -s -p "password: " password
if [ "$env" == "prod" ] ; then
url=http://manager.hadoop.werally.in:7180/api/v10/hosts
elif [ "$env" == "blue" ] ; then
url=http://manager.hadoop-bluesteel.werally.in:7180/api/v10/hosts
You can’t perform that action at this time.