Skip to content

Instantly share code, notes, and snippets.

View mathieul's full-sized avatar

Mathieu Lajugie mathieul

View GitHub Profile
@mathieul
mathieul / gist:966776
Created May 11, 2011 16:12
Require files using RequireJS before running Jasmine specs
/*
* jasmine.requirejs() returns a function that will load the file(s) required
* and will wait until it's done before proceeding with running specs.
* The function returned is intended to be passed to beforeEach() so the file(s)
* is(are) loaded before running each spec.
*
* Syntax:
*
* jasmine.requirejs(options, files)
* or
@mathieul
mathieul / boot.rb
Created November 3, 2011 16:59
Rails 2.3.5 boot.rb file
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
@mathieul
mathieul / lead_form.rb
Created May 22, 2012 20:03
Caring Form
# app/forms/lead_form.rb
class LeadForm < CaringForm::Model
protect_from_bots
index_on :form_location
metadata :resource_type, :ancillary => true
metadata :inquiry_key
full_name :name
tel :phone_number
email :email_address
@mathieul
mathieul / gist:3189204
Created July 27, 2012 17:11
Re-enable the delete key as shortcut for Back in Safari 6
  • quit Safari

  • go to Keyboard System Preferences and click on the Keyboard Shortcuts tab

  • select Application Shortcuts, click on + to add a new one:

    • Application: Safari
    • Menu Title: Back
    • Keyboard shortcut: type ⌘$
  • open ~/Library/Preferences/com.apple.Safari.plist with a plist editor (i.e.: XCode)

  • look for "NSUserKeyEquivalents" dictionary

  • open it

@mathieul
mathieul / assert_forty_two.rb
Last active December 16, 2015 04:19
Monitoring SQL assertions and other type
class AssertFortyTwo
include SystemStateAssertion
describe "the Answer to the Ultimate Question of Life, the Universe, and Everything to be 42"
expect 42
def actual
2
end
end
@mathieul
mathieul / application_router.ex
Created September 6, 2013 04:24
Example of websocket handler
defmodule ApplicationRouter do
use Dynamo.Router
prepare do
conn.fetch([:params])
end
post "/publish" do
room_id = conn.params[:room_id]
data = conn.params[:data]
@mathieul
mathieul / DiscussionMessage.elm
Created August 12, 2016 17:47
First (complicated) pass at extracting a list of DiscussionMessage items
module Online.DiscussionMessage exposing (receiveCollection)
import Dict exposing (Dict)
import Json.Decode as JD
import Json.Encode as JE
import JsonApi
import JsonApi.Documents
import JsonApi.Decode
import JsonApi.Resources
import Online.Types exposing (Model, Msg, DiscussionMessage, Chatter)
@mathieul
mathieul / ember-cli-build.js
Created December 21, 2015 18:27
Using ES7 decorators & async/await with Ember: example
// ...
var app = new EmberApp(defaults, {
hinting: false,
babel: {
includePolyfill: true,
optional: [
"es7.decorators",
"es7.classProperties",
"es7.asyncFunctions"