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| const INTERVAL = 100; | |
| function myFunction () { | |
| setTimeout(() => { | |
| console.log('hi'); | |
| }, INTERVAL); | |
| } | |
| describe('myFunction', () => { | |
| it('should be testable', () => { |
| // modified from https://stackoverflow.com/a/22650574 | |
| function cropSVG () { | |
| var mySVG = document.querySelector('svg'); | |
| var bb = mySVG.getBBox(); | |
| var vb = [bb.x, bb.y, bb.width, bb.height]; | |
| mySVG.setAttribute("viewBox", vb.join(" ")); | |
| copy(mySVG.outerHTML); | |
| } |
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| function * fibonacci (one = 1, two = 1) { | |
| let sum = one + two; | |
| yield sum; | |
| yield * fibonacci(two, sum); | |
| } |
| export const gatherChars = str => str | |
| .match(/(.)\1*/g) | |
| .map(s => `${s.charAt(0)}${s.length}`) | |
| .join(''); |
| angular.factory('foo', ['Restangular', (Restangular) => { | |
| return Restangular.one('foo', 1); | |
| }]); |
| git diff-tree --no-commit-id --name-only -r your-branch-name | xargs sed -ie 's/oldName/newName/g' |
| git for-each-ref --sort=-committerdate refs/heads/ |
| # converts a png image to jpeg | |
| # all transparent regions will be converted to white | |
| convert -flatten source.png destination.jpg |
| class ThingController < ApplicationController do | |
| # ... | |
| protected | |
| def protected_thing | |
| 'foo' | |
| end | |
| private | |