This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Homebrew | |
case $(uname -m) in | |
"arm64") | |
export PATH="/opt/homebrew/bin:$PATH" | |
export RBENV_ROOT="/opt/homebrew/opt/rbenv" | |
;; | |
"x86_64") | |
export PATH="/usr/local/bin:$PATH" | |
export RBENV_ROOT="~/.rbenv" | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GIFme | |
# This is a really simple/stupid command line (specifically zsh) function to copy public Dropbox links to your gifs. | |
# | |
# Put this somewhere in your .zshrc and replace {{YOUR_PUBLIC_ID}} with your public Dropbox ID (find this by going to dropbox.com, finding a file in your "Public" folder, selecting it and clicking "Copy public link", and looking for the long number in the URL) | |
# | |
# This assumes your gifs (and other images you want to share) are stored in your Dropbox "Public" folder in a directory called "gifs". | |
# This whole thing ain't pretty, and it could be much better. But it's a start. | |
# | |
# Usage: | |
# "$ gifme yup.gif" will copy a public link to "{{Dropbox Directory}}/Public/gifs/yup.gif" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello = React.createClass({ | |
componentWillMount: function() { console.log('componentWillMount') }, | |
componentDidMount: function() { console.log('componentDidMount') }, | |
render: function() { | |
return DOM.div({ class: 'container' }, [ | |
DOM.span({ | |
data: { | |
foo: { bar: 'baz' }, | |
much: { much: 'fun' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tabname() { printf "\e]1;$1\a" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rdio console: http://rdioconsole.appspot.com | |
# Get a track: http://rdioconsole.appspot.com/#keys%3Dt[INSERT 7 DIGITS NUMBER HERE]%26method%3Dget | |
def get_random_number | |
1_000_000 + Random.rand(10_000_000 - 1_000_000) | |
end | |
track_key = get_random_number | |
puts track_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def image_container(path, width, height) | |
%(<div class="image-container" style="max-width: #{width}px"> | |
<div style="padding-top: #{(height.to_f / width.to_f) * 100}%"> | |
#{image_tag(path)} | |
</div> | |
</div>).html_safe | |
end | |
# Note: If you want the image to scale up, remove the `max-width` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works with Zepto/jQuery | |
$.fn.add_at_index = function(content, index) { | |
if (index < 0) { index = 0 } | |
this.each(function() { | |
var $this = $(this) | |
var $child = $this.children().eq(index) | |
if ($child.length) { return $child.before(content) } | |
$this.append(content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works with Zepto/jQuery | |
$.fn.one_for_all = function(type, callback) { | |
var $all = $(this) | |
$all.on(type, function(e) { | |
$all.off(type) | |
callback(e) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def javascript_content(file_name) | |
Rails.application.assets[file_name].source.html_safe | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var handleRequest = function(data) { | |
postMessage(data) | |
} | |
addEventListener('message', function(e) { | |
var xhr = new XMLHttpRequest | |
xhr.open('GET', e.data) | |
xhr.onreadystatechange = function(e) { | |
if (xhr.readyState === 4 && xhr.status === 200) { | |
handleRequest(xhr.responseText) |
NewerOlder