This file contains hidden or 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
angular.module('myModule', []) | |
.directive('myDirective', myDirective); | |
function myDirective () { | |
return { | |
restrict: 'E', | |
scope: { | |
inputName: '@', | |
model: '=' | |
}, |
This file contains hidden or 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
<body> | |
<section class="header"> | |
<h1>My Page</h1> | |
</section> | |
<article class="content"> | |
<h2>The things I am putting on the internet</h2> | |
<p>Jack swab salmagundi Brethren of the Coast knave line plunder belaying pin Admiral of the Black boom. Sloop pink holystone yard pillage tender no prey, no pay Pirate Round chandler bilge water. Transom careen rum keelhaul lanyard man-of-war rope's end grog pinnace bucko.</p> | |
<p>Bilged on her anchor chase Jolly Roger coffer jury mast rum grapple interloper hearties keel. Avast chantey Jolly Roger fathom scallywag matey Spanish Main booty Corsair Plate Fleet. Fluke Buccaneer cog yo-ho-ho spirits loaded to the gunwalls pillage gunwalls gally holystone.</p> | |
<p>League stern maroon quarter fore jack grog blossom American Main clipper pressgang. Ho tack landlubber or just lubber run a shot across the bow grapple boom cutlass long clothes hands reef. Jack Tar Buccaneer Sail ho aye spyglass run a rig Brethren of the Coast carouser parrel landlubber or just |
This file contains hidden or 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
# let's say I want to execute a callback before making a FactoryGirl fixture using #create | |
factory :thing do | |
before(:create) do |foo| | |
foo.bar = create :baz | |
end | |
end | |
# but then I also want to call the same block after making a FactoryGirl fixture using #build | |
factory :thing do | |
before(:create) do |foo| |
This file contains hidden or 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
# OpternaTip | |
# so you don't have to ping our server for restoring your local database multiple times | |
bundle exec rake db:restore:file[./tmp/database/staging-2016-03-16.sql.gz] |
This file contains hidden or 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
/* | |
closest(0.5, [0, 1, 2, 3]); // 1 | |
closest(0.4, [0, 1, 2, 3]); // 0 | |
*/ | |
function closest (num, arr) { | |
if (!arr || !arr.length) { | |
return; | |
} | |
return arr.slice(0).sort(function (a, b) { |
This file contains hidden or 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
#!/bin/bash | |
# place this script in ~/bin/ | |
# and update your .bash_profile or .bashrc with: | |
# export PATH="$HOME/bin/" | |
GIF=$(ruby -e "require 'net/http';require 'json';json=Net::HTTP.get(URI('https://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=hotline%20bling'));output=JSON.parse(json);puts output['data']['image_url']") | |
# this uses the giphy public beta api key, for demonstration only | |
# replace this key with your own key, please |
This file contains hidden or 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
const makeCube = (d = 0) => { | |
let arr = new Array(SIZE); | |
if (d === DIMENSIONS) { | |
return arr.fill(0); | |
} | |
return arr.fill(makeCube(d + 1)); | |
}; | |
const cube = makeCube(); |
This file contains hidden or 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
function replaceSrc (html) { | |
// matches img tags, captures src | |
var imgSrcRegex = /\<img(.*)src\s?=\s?"(.*)"(.*)\>/gi; | |
// replaces src with data-original to ensure compatibility | |
// with jquery lazyload api | |
return html.replace(imgSrcRegex, '<img$1data-original="$2"$3>'); | |
} |
This file contains hidden or 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
#!/bin/sh | |
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".js\{0,1\}") | |
if [[ "$STAGED_FILES" = "" ]]; then | |
exit 0 | |
fi | |
PASS=true |
This file contains hidden or 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
" Set the title of the Terminal to the currently open file | |
function! SetTerminalTitle() | |
let titleString = expand('%:t') | |
if len(titleString) > 0 | |
let &titlestring = expand('%:t') | |
" this is the format iTerm2 expects when setting the window title | |
let args = "\033];".&titlestring."\007" | |
let cmd = 'silent !echo -e "'.args.'"' | |
execute cmd | |
redraw! |