Skip to content

Instantly share code, notes, and snippets.

View ethagnawl's full-sized avatar
🐢

Pete Doherty ethagnawl

🐢
View GitHub Profile
@ethagnawl
ethagnawl / palindrome.rb
Last active December 17, 2015 15:09
A simple palindrome matcher.
def palindrome?(x)
x = x.to_s
if x.length == 1
return true
elsif (x.length % 2) == 0
a = x[0..(x.length / 2 - 1)]
b = x[(x.length / 2)..(x.length)].reverse
else
x = x.split('')
@ethagnawl
ethagnawl / gist:5811717
Created June 19, 2013 04:41
Conditional HAML Class
- klass = @feed.fav_post ? 'favorited' : ''
.UI_feed_item.deletable.clearfix{ class: klass, feed_id: "#{@feed.id}", id: "feed_item_#{@feed.id}" }
@ethagnawl
ethagnawl / gist:6526200
Last active December 22, 2015 20:28
Sum Harvest App Quantity Column
var inputs = [].slice.call(document.querySelectorAll('.quantity'));
inputs = inputs.filter(function (x) { return x.children[0] && x.children[0].classList.contains('js-change-total') });
inputs.reduce(function (x,y) { return x + parseFloat(y.children[0].value) }, 0);
@ethagnawl
ethagnawl / gist:6545400
Created September 13, 2013 00:03
NYC WIFI
establishment name | network name | network password
One Girl Cookies | One Girl Cookies | cupcakes
Tugboat Tea Company | Tugboat Tea Co. | plugin@tug
@ethagnawl
ethagnawl / gist:6785716
Last active July 15, 2016 19:36
Run shell command in SBCL REPL
;; CL (ext:shell (...))
;; SBCL (sb-ext:run-program (...))
@ethagnawl
ethagnawl / gist:7256910
Created October 31, 2013 20:49
naive first unique letter of string function in JavaScript
function firstNonRepeatingLetter (str) {
var str_arr = str.split('');
return str_arr.filter(function (x) {
return str_arr.indexOf(x) === str_arr.lastIndexOf(x);
})[0];
}
firstNonRepeatingLetter('aardvark') === 'd' // true
@ethagnawl
ethagnawl / gist:7517664
Last active July 25, 2016 12:47
slime-like tmuxinator config yml
# ~/.tmuxinator/slime.yml
name: slime
root: ~/
windows:
- editor:
layout: main-vertical
panes:
- vim
@ethagnawl
ethagnawl / gist:7936876
Created December 12, 2013 22:42
HAML link_to with block
= link_to(some_path, {class: 'btn btn-large'}) do
%i.icon-plus-sign
Do Some Thing
@ethagnawl
ethagnawl / default.clj
Created December 21, 2013 00:02
Clojure Default Parameters
(defn foo
([] (foo "bar"))
([bar] (prn bar)))
(foo) ;; "bar"
(foo "baz") ;; "baz"
@ethagnawl
ethagnawl / gist:8078927
Created December 22, 2013 05:58
What is a monad?
"A monad is a collection of functions that can be used to modify stepwise calculations." - Marick