Skip to content

Instantly share code, notes, and snippets.

View ssaunier's full-sized avatar

Sébastien Saunier ssaunier

View GitHub Profile
@ssaunier
ssaunier / livestats_ducksboard_cron.php
Created December 4, 2011 16:34
Cronjob for ssaunier/livestats and a Ducksboard dashboard
<?php
/*
* A usage example for the livestats project pushing data
* to a Ducksboard dashboard.
*
* https://github.com/ssaunier/livestats
* https://ducksboard.jira.com/wiki/display/API/API+Reference
*
* Copyright 2011, Sébastien Saunier <sebastien.saunier@gmail.com>
@ssaunier
ssaunier / generate_api_controller.sh
Created May 10, 2012 09:42
Generate a Rails controller in namespace /api/v1
#! /bin/sh
if [ $# -eq 0 ]; then
echo "Usage: ./generate_api_controller.sh CONTROLLER"
exit 1
fi
bundle exec rails generate controller "api/v1/$1" --no_helper --no_assets
rm -rf app/views/api
@ssaunier
ssaunier / .gitignore
Created September 11, 2012 13:19
Retina responsive sprites with smart touch hover behavior
.DS_Store
.sass-cache
public/images/stickers-retina-s28fb90c6bd.png
public/images/stickers-s8db04c2c8a.png
public/stylesheets/application.css
@ssaunier
ssaunier / symbolizer.rb
Last active May 15, 2018 18:34
Recurively symbolize ruby object keys
module Symbolizer
def self.deep_symbolize(object)
if object.kind_of? Hash
object.keys.each do |k|
object[k == "_id" ? :id : k.to_sym] = self.deep_symbolize(object.delete k)
end
object
elsif object.kind_of? Array
object.map { |e| self.deep_symbolize e }
else
@ssaunier
ssaunier / .gitignore
Created December 4, 2012 16:00
Build Event registration form with Liquid
result.html
Gemfile.lock
@ssaunier
ssaunier / .watchr
Created December 12, 2012 11:01
Lightweight alternative to guard. Run rspec over spork as you code watching changes to your code base.
def run_spec(file)
unless File.exist?(file)
puts "#{file} does not exist, no specs to run."
return
end
puts "Running #{file}"
system "bundle exec rspec #{file} --drb --colour"
puts
end
@ssaunier
ssaunier / zoho.rb
Last active November 3, 2017 16:56
Simple REST Client for the Zoho Invoice API, using HTTParty. You can search for customers, create a new one, create a new invoice, add a payment and send it.
# Copyright Applidget - 2013
# Author : Sébastien Saunier (@ssaunier)
# Released under MIT License
require "httparty"
class Zoho
include HTTParty
base_uri 'invoice.zoho.com:443/api'
@ssaunier
ssaunier / init_git_repo.sh
Last active December 15, 2015 14:49
Script to init a git repository on a server to easily deploy several website via git (think Heroku!). Useful for Apache + PHP for instance. Bonus: Deployment versioning and custom "install.sh" script run if foud.
#!/bin/sh
# Copyright Sébastien Saunier (@ssaunier) - 2013
# License: MIT
#
# Script to run at the root of an apache folder where you want to deploy with git.
# It will create a repository where you can push, and set up a post-receive script
# with is run each time this server gets pushed a new version:
#
# 1. post-receive compute the new version number based on existing ones
# in the $DEPLOYMENT_TARGET_ROOT folder
@ssaunier
ssaunier / regexp_extension.rb
Last active August 10, 2020 06:41
Create regex patterns insensitive to accented characters
# Copyright: Applidget - 2013
# License: MIT
# Author: Sébastien Saunier (@ssaunier)
#
# Create regex patterns insensitive to accented characters
# Useful when querying a name in MongoDB
# Mapping array source: http://stackoverflow.com/a/228006/197944, with a .gsub("\\x", "\\u00")
class RegexpExtension
@ssaunier
ssaunier / cookiebot.js
Last active December 24, 2015 03:59 — forked from jeresig/cookiebot.js
clickInterval = setInterval(function(){
// Click the large cook as fast as possible!
$("#bigCookie").click();
// Sometimes a golden cookie will appear to give you a bonus
// Click that too!
$("#goldenCookie").click();
}, 1);