Skip to content

Instantly share code, notes, and snippets.

View bignimbus's full-sized avatar
🙃

Jeff Auriemma bignimbus

🙃
View GitHub Profile
@bignimbus
bignimbus / gather-chars.js
Created September 9, 2016 21:19
'aabbbc' -> 'a2b3c1'
export const gatherChars = str => str
.match(/(.)\1*/g)
.map(s => `${s.charAt(0)}${s.length}`)
.join('');
@bignimbus
bignimbus / foo-service.js
Last active August 1, 2016 18:46
Writing a unit test for an angular controller or factory that uses Restangular shouldn't be hard, but it is. Here's how to set it up.
angular.factory('foo', ['Restangular', (Restangular) => {
return Restangular.one('foo', 1);
}]);
@bignimbus
bignimbus / git-method-rename-fun.sh
Last active July 12, 2016 18:19
Execute a global rename only on files that were modified in a particular git branch. Useful for renaming files after a code review and never "missing a spot."
git diff-tree --no-commit-id --name-only -r your-branch-name | xargs sed -ie 's/oldName/newName/g'
@bignimbus
bignimbus / order-git-branches.sh
Created June 13, 2016 17:27
showing git branches in chronological order
git for-each-ref --sort=-committerdate refs/heads/
@bignimbus
bignimbus / imagemagick-convert.sh
Last active April 24, 2020 21:03
Here are some of my pet ImageMagick commands.
# converts a png image to jpeg
# all transparent regions will be converted to white
convert -flatten source.png destination.jpg
@bignimbus
bignimbus / thing_controller.rb
Last active April 29, 2016 17:03
Testing protected and private methods in rspec
class ThingController < ApplicationController do
# ...
protected
def protected_thing
'foo'
end
private
@bignimbus
bignimbus / flexbox-columns.html
Last active April 12, 2016 14:56
Using flexbox to order a columned list top -> bottom then left -> right instead of the opposite. http://codepen.io/bignimbus/pen/LNQarP
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>Example</h1>
<section>
<!--
I want to display these numbers in two columns like so:
@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|