Skip to content

Instantly share code, notes, and snippets.

View Olical's full-sized avatar
🧙‍♂️
(magic)

Oliver Caldwell Olical

🧙‍♂️
(magic)
View GitHub Profile
ZSH_THEME_GIT_PROMPT_DIRTY='%Uλ%u'
ZSH_THEME_GIT_PROMPT_CLEAN='λ'
local lambda='%(?,%{$fg[green]%},%{$fg[red]%})$(parse_git_dirty)%{$reset_color%} '
PROMPT="$lambda"
@Olical
Olical / javascript-expand.vim
Last active August 29, 2015 14:22
Auto expansion for my JavaScript conceal characters based on syntax type
" These bindings allow my conceal characters to work both ways. So if I type
" @, it is actually translated to this. I have conceal set up to render this
" as @. So I essentially have my own flavour of JavaScript but only in my Vim.
" Fantastic.
" Returns a mapped version of the list.
" http://learnvimscriptthehardway.stevelosh.com/chapters/39.html#higher-order-functions
function! Mapped(fn, l)
let new_list = deepcopy(a:l)
call map(new_list, string(a:fn) . '(v:val)')
@Olical
Olical / lazyArray.js
Created May 22, 2015 09:26
Some experiments with lazy arrays in JavaScript inspired by Clojure's lazy-seq
function LazyValue(fn) {
this.valueOf = fn;
}
function lazyArray(fn) {
return [new LazyValue(fn)];
}
function cons(item, arr) {
return [item].concat(arr);
0 101010
1 111111
-1 111010
D 001100
A 110000 M
!D 001101
!A 110001 !M
-D 001111
-A 110011 -M
D+1 011111
@Olical
Olical / model.clj
Created May 16, 2015 13:36
Model for lisp cast thing at Hack the Tower
(ns webdev.item.model
(:require [clojure.java.jdbc :as db]))
(defn create-table [db]
(db/execute!
db
["CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\""])
(db/execute!
db
["CREATE TABLE IF NOT EXISTS items
@Olical
Olical / cows.txt
Created April 29, 2015 14:03
for cow in $(ls /usr/share/cows); do fortune | cowsay -f $cow; echo; done > cows.txt
__________________________________
< Money is the root of all wealth. >
----------------------------------
\ __------~~-,
\ ,' ,
/ \
/ :
| '
| |
| |
@Olical
Olical / throttle-check
Created April 21, 2015 16:44
Throttle your localhost. (for Linux)
#!/usr/bin/env bash
if [[ -f /tmp/throttle-check ]]; then
echo "Currently throttling at $(cat /tmp/throttle-check). (throttle-off to stop)"
else
echo "Not currently throttling. (throttle-on to start)"
fi
var elements = {
button: document.getElementById('thebutton'),
title: document.querySelector('.thebutton-form > h1'),
times: [
'10s',
'1s',
'100ms',
'10ms'
].map(function (id) {
return document.getElementById('thebutton-s-' + id);
/**
* Turns a number (in number or string form) into a string with commas used as
* a thousands separator.
*
* Example: 10000000 -> 10,000,000
*
* @param {String|Number} num
* @return {String}
*/
function formatNumberWithCommas(num) {
#!/usr/bin/env bash
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
cat >>~/.vimrc <<EOL
set nocompatible
call plug#begin()
Plug 'tpope/vim-sensible'