Skip to content

Instantly share code, notes, and snippets.

View sgruhier's full-sized avatar

Sébastien Gruhier sgruhier

  • https://xilinus.com
  • Saint-Paul en Forêt
  • X @sgruhier
View GitHub Profile
anonymous
anonymous / oshi.rb
Created July 8, 2010 08:18
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'json'
class Connection
attr_accessor :socket, :user_id
def initialize(socket, user_id)
@socket = socket
#!/usr/bin/env ruby
# aquamacs-editor: my $EDITOR for Aquamacs. Starts Aquamacs, waits
# for emacs-server to load, then runs emacsclient with the given
# arguments. If data is piped to stdin, it's buffered to a temporary
# file and passed to emacsclient instead. Waits for 'C-x #' unless
# invoked with -n.
#
# sstephenson 2010-09-12
require "tempfile"
@netzpirat
netzpirat / 0_README.md
Created November 12, 2010 10:42
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@sstephenson
sstephenson / back_forward.js
Created December 13, 2010 21:55
How to detect whether a hash change came from the Back or Forward button
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
@abtris
abtris / zend-mail-example
Created April 12, 2011 17:41
Mock Smtp example
<?php
require_once 'Zend/Mail.php';
require_once 'Zend/Mail/Transport/Smtp.php';
$config = array();
$config['host'] = "localhost";
$config['port'] = 1025;
$config['username'] = "";
$config['password'] = "";
# Extend jQuery objects with Underscore collection methods.
#
# Each collection method comes in two flavors: one prefixed
# with _, which yields a bare DOM element, and one prefixed
# with $, which yields a jQuery-wrapped element.
#
# So if `this` is a jQuery object, instead of:
#
# _.max @, (el) -> $(el).height()
#
@paulirish
paulirish / data-markdown.user.js
Last active February 6, 2024 10:41
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@solisoft
solisoft / ovhfact.rb
Created January 20, 2012 09:25
OVH Invoices
#!/usr/bin/ruby
# Require:
# - linux or Mac
# - ruby 1.8.7
# - Gem soap4r
# - curl
#
# Usage :
# ruby ovhfact.rb 2011
#
@carlzulauf
carlzulauf / geodist.rb
Created February 2, 2012 16:57
Ruby haversine distance method, in miles
def geodist(a, b)
rads = Math::PI/180
# 7926.3352 is diameter of earth in miles
7926.3352 * Math.asin(
Math.sqrt(
Math.sin( (b[1] - a[1])*rads / 2 )**2 *
Math.cos( a[0] * rads ) *
Math.cos( b[0] * rads ) +
Math.sin( (b[0] - a[0])*rads / 2 )**2
)
@lancejpollard
lancejpollard / index.md
Created May 22, 2012 06:32
Notes on Ember.js overcomplicating...

Some random notes on the pangs of ember. Will be expanding as they are uncovered.

Building a form

Say you have a form that maps to a model, something like:

<form>
  <fieldset>
    <legend>Who are you?</legend>