Skip to content

Instantly share code, notes, and snippets.

@mrsweaters
mrsweaters / ruby_class_fun.rb
Last active August 29, 2015 14:03
Ruby Classe Stuff
names = []
@topics.each do |topic|
names << topic.name
end
names
names = @topics.map do |topic|
topic.name
end
@mrsweaters
mrsweaters / iframe.html
Created July 1, 2014 16:25
Video Embed
<iframe src="//fast.wistia.net/embed/iframe/qnr7gv5l8i?videoFoam=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="720" height="405"></iframe><script src="//fast.wistia.net/assets/external/iframe-api-v1.js"></script>
@mrsweaters
mrsweaters / remove.sh
Created July 3, 2014 21:08
unbuntu remove files older than X days
find /path/to/files* -mtime +5 -exec rm {} \;
# five represents the number of days.
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
import math
import Image
import Levenshtein
class BWImageCompare(object):
"""Compares two images (b/w)."""
_pixel = 255
@mrsweaters
mrsweaters / git.sh
Last active August 29, 2015 14:04
delete all local branches
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
or
git branch --merged master | grep -v 'master$' | xargs git branch -d
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
def pbpaste
`pbpaste`
end
@mrsweaters
mrsweaters / toggle-area.js
Created August 18, 2014 21:56
toggle-aria
init : function (scope, libraries, method, options, response) {
var args = [scope, method, options, response],
responses = [];
if (libraries == 'toggleAriaObject') {
return this.utils.toggleAriaObject(scope, method);
}
// check RTL
this.rtl = /rtl/i.test(S('html').attr('dir'));
@mrsweaters
mrsweaters / specs.sh
Created August 19, 2014 06:46
mac system specs
system_profiler SPHardwareDataType
@mrsweaters
mrsweaters / haiku
Created August 25, 2014 06:12 — forked from friggeri/haiku
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",