Skip to content

Instantly share code, notes, and snippets.

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

Oliver Caldwell Olical

🧙‍♂️
(magic)
View GitHub Profile
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);
@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 / 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
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 / 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);
@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)')
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 / Oliver Caldwell's JavaScript toolbox.md
Created March 24, 2011 15:07
This is an example implementation of Mappa (github.com/Wolfy87/Mappa)

This is an example implementation of Mappa (github.com/Wolfy87/Mappa)

So all you need to do is include the Mappa script which you can download from the repo. The minified version is absolutely tiny.

Then include toolbox.js. Then what do ya know! It just works. Now if you scroll to the bottom of toolbox.js you will see the mappings. It is self explaining documentation. To learn about the functions you will need to go to their respective docs which are linked to from the read me. The read me can be found in the repository.

For example, here is how you dump all of the cookies from the page.

@Olical
Olical / Redirect301Regex.md
Created March 28, 2011 10:12
Turn a table of urls into a list of 301 redirects
@Olical
Olical / Example JavaScript objects.js
Created March 31, 2011 16:27
Blog post: Data normalisation with Mappa
var newsFeed = {
meta: {
foo: 'bar',
etc: 12345
},
results: [
{
t: 'New GCC compiler',
more: {
u: 'http://reddit.com/'