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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / fibonacci-generator.js
Last active September 16, 2016 19:18
Recursive sequential generator of Fibonacci numbers
function * fibonacci (one = 1, two = 1) {
let sum = one + two;
yield sum;
yield * fibonacci(two, sum);
}

Say you have a model that has_many of another model through a third, intermediary model.

class Foo
  has_many :bar_infos
  has_many :bars, through: :bar_infos

  accepts_nested_attributes_for :bar_infos
end