Skip to content

Instantly share code, notes, and snippets.

View bignimbus's full-sized avatar
🙃

Jeff Auriemma bignimbus

🙃
View GitHub Profile
@bignimbus
bignimbus / ng-model-directive.js
Created March 30, 2016 18:15
Inheriting ngModel in an Angular directive
angular.module('myModule', [])
.directive('myDirective', myDirective);
function myDirective () {
return {
restrict: 'E',
scope: {
inputName: '@',
model: '='
},
@bignimbus
bignimbus / layout.html
Last active March 29, 2016 19:29
Using calc + vh to elegantly enforce 100% content area height
<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
@bignimbus
bignimbus / callbacks.rb
Created March 28, 2016 16:36
Using FactoryGirl callbacks
# 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|
@bignimbus
bignimbus / restoring-local-backup.sh
Last active March 17, 2016 15:21
[OpternaTip] restoring database from a local archive
# 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]
@bignimbus
bignimbus / closest.js
Last active February 5, 2016 21:45
Given a number and an array of numbers, return the number in an array that is closest to that number.
/*
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) {
@bignimbus
bignimbus / drake
Last active June 13, 2016 20:48
drake - rake but with a drake gif
#!/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
@bignimbus
bignimbus / array-of-arrays.js
Last active January 11, 2016 19:10
Representing a multidimensional plane in javascript
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();
@bignimbus
bignimbus / img-regex.js
Created January 4, 2016 20:09
Parsing img tags in markup for jquery lazyload at runtime
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>');
}
@bignimbus
bignimbus / pre-commit-eslint
Created December 17, 2015 20:23 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/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
@bignimbus
bignimbus / .vimrc
Last active February 14, 2025 14:18
Set iTerm2 title to current buffer in vim
" 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!