Skip to content

Instantly share code, notes, and snippets.

Avatar

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 gulpfile.js
/*
* Gulp plugins
*/
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var babel = require('gulp-babel');
var browserSync = require('browser-sync');
var cache = require('gulp-cache');
var concat = require('gulp-concat');
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 test_object.coffee
TestObject = Parse.Object.extend
className: "TestObject"
validate: (attributes, options) ->
console.log 'validating'
return "foo"
t = new TestObject
t.save()
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",
You can’t perform that action at this time.