Skip to content

Instantly share code, notes, and snippets.

@mathieul
mathieul / DiscussionMessage.elm
Created Aug 12, 2016
First (complicated) pass at extracting a list of DiscussionMessage items
View DiscussionMessage.elm
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 Dec 21, 2015
Using ES7 decorators & async/await with Ember: example
View ember-cli-build.js
// ...
var app = new EmberApp(defaults, {
hinting: false,
babel: {
includePolyfill: true,
optional: [
"es7.decorators",
"es7.classProperties",
"es7.asyncFunctions"
@mathieul
mathieul / application_router.ex
Created Sep 6, 2013
Example of websocket handler
View application_router.ex
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 / assert_forty_two.rb
Last active Dec 16, 2015
Monitoring SQL assertions and other type
View assert_forty_two.rb
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 / gist:3189204
Created Jul 27, 2012
Re-enable the delete key as shortcut for Back in Safari 6
View gist:3189204
  • 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
View lead_form.rb
# 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 / boot.rb
Created Nov 3, 2011
Rails 2.3.5 boot.rb file
View boot.rb
# 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 / gist:966776
Created May 11, 2011
Require files using RequireJS before running Jasmine specs
View gist:966776
/*
* 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