Skip to content

Instantly share code, notes, and snippets.

Jacob Smith jacobthemyth

View GitHub Profile
View example.rb
class Example
define_method(:call) do
yield if block_given?
end
end
View emacs_mode.lua
-- http://www.hammerspoon.org/docs/hs.hotkey.html
local function keyCode(key, modifiers)
modifiers = modifiers or {}
return function()
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), true):post()
hs.timer.usleep(1000)
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), false):post()
end
View rspec_table_spec.rb
RSpec.describe "Using a table for multiple examples" do
def self.define_data_table(name, table_doc)
fields, *records = *table_doc.lines.map { |l| l.split('|').map(&:strip).reject(&:empty?) }
define_singleton_method(name) { records.map { |r| Hash[fields.map(&:to_sym).zip(r)] } }
end
define_data_table(:users, <<~USERS)
| name | email | twitter |
| Aslak | aslak@cucumber.io | @aslak_hellesoy |
| Julien | julien@cucumber.io | @jbpros |
View install-script.sh
#!/bin/sh
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
echo "Setting up XCode"
View application.route.js
import Ember from 'ember';
export default Ember.Route.extend({
'things-store': Ember.inject.service('things-store'),
model() {
console.log('model', this.get('things-store.things').length);
this.get('things-store').fetch();
console.log('post', this.get('things-store.things').length);
return this.get('things-store');
},
View model.md

Account

{
  "name": "Account Name",
  "starting_balance": 354745, // Number in pennies
  "starting_balance_date": "2015-03-15",

  "current_balance": 269439 // Number in pennies
  "current_balance_date": "2015-07-03",
View store.js
import ForecastCollection from './models';
let forecasts = new ForecastCollection();
var Store = _.extend({}, Backbone.Events, {
initialize() {
this.listenTo(forecasts, 'add remove change', () => this.trigger('change'));
},
getForecasts() {
View store.js
let forecasts = new ForecastCollection();
var Store = _.extend({}, Backbone.Events, {
initialize() {
this.listenTo(forecasts, 'add remove change', () => this.trigger('change'));
},
getForecasts() {
return forecasts.toJSON();
},
You can’t perform that action at this time.