Skip to content

Instantly share code, notes, and snippets.

@rsslldnphy
rsslldnphy / to_donut.rb
Created May 13, 2014 16:35
My first submission to Ruby Core
class BasicObject
def to_donut
:donut
end
end
## Usage
3.to_donut #=> :donut
nil.to_donut #=> :donut
{- | given two positions in a list, swap them.
if (at least) one of the positions is invalid, return Nothing.
Examples:
>>> swapL 0 2 [0..5]
Just [2,1,0,3,4,5]
>>> fmap (take 6) $ swapL 0 2 [0..]
Just [2,1,0,3,4,5]
{-- | List the sub-sequences of conscutives elements in the list such that the
sum of the element is equal to the given number.
Examples:
>>> matchingSub 10 [1..5]
[[1,2,3,4]]
>>> matchingSub 2 $ replicate 3 1
[[1,1],[1,1]]
{-| Keep equal elements that are at the same position in both lists
Examples:
>>> keepEqual "hello" "world"
"l"
>>> keepEqual (repeat 1) [0..10]
[1]
@rsslldnphy
rsslldnphy / help.js
Created July 29, 2014 13:34
Living the Jenn Schiffer dream!
(function() {
var d = document, body = d.querySelector('body'), popup = d.createElement('div');
popup.className = 'call-centre-help';
popup.style.visibility = 'hidden';
popup.style.position = 'fixed';
popup.style["z-index"] = 100000;
popup.style["background-color"] = "blue";
popup.style.color = "white";
@rsslldnphy
rsslldnphy / annoy.txt
Last active August 29, 2015 14:06
Emacs/Evil-Mode annoyances
* 'p' pastes over lines rather than inserting new ones
* 'dd' doesn't work - it should call `evil-paredit-kill-line`
* can't map ad-hoc keybindings
* :e doesn't work from top-level of project, but level of current file
@rsslldnphy
rsslldnphy / gist:491749d9f5b0afabd1c2
Last active August 29, 2015 14:06
Quick and dirty hacky script to test out many vim colorschemes quickly
for f in `ls -1 ~/.vim/colors`; do
echo colorscheme $(echo $f | awk -F'.' '{print $1}') >> ~/.vimrc
echo ";; $(echo $f | awk -F'.' '{print $1}')" >> example.clj
vim example.clj
echo "that was $f"
sed '$d' ~/.vimrc > .vimrc.new
sed '$d' example.clj > example.new
mv .vimrc.new ~/.vimrc
mv example.new example.clj
done
@rsslldnphy
rsslldnphy / .tmux.conf
Last active August 29, 2015 14:06
TMUX stuff
set-option -g default-command "reattach-to-user-namespace -l bash"
# Smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l"
(ns coins)
(def heads (repeat 50 :H))
(def tails (repeat 50 :T))
(def flip {:H :T :T :H})
(defn permutation [n]
[(concat (take n heads) (drop n tails))
(concat (drop n heads) (take n tails))])
@rsslldnphy
rsslldnphy / .tmux.conf
Created October 7, 2014 11:53
OSX, TMUX, VIM... *and* copy and paste
set-option -g default-command "reattach-to-user-namespace -l bash" # <- supposed to sort it globally, but doesn't always work for me
# Smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l"
bind k confirm kill-session