Skip to content

Instantly share code, notes, and snippets.

View thbar's full-sized avatar

Thibaut Barrère thbar

View GitHub Profile
@krasio
krasio / custom.conf.erb
Created October 30, 2012 08:40
Simple Chef recipe to customize Nginx configuration on Engine Yard App Cloud
# cookbooks/nginx-custom/templates/default/custom.conf.erb
rewrite ^/members/(.*)/blog_entries/(.*)$ /members/$1/blog/$2 permanent;
@seanlilmateus
seanlilmateus / rubymotion_ispeech.md
Created July 19, 2012 13:51 — forked from creativetechnologist/rubymotion_ispeech
Integrating RubyMotion and the iSpeech SDK

#Integrating RubyMotion and the iSpeech SDK

As of 19th July 2012, RubyMotion has a couple of issues with external libraries as I discovered when trying the integration, thanks to Laurent, the architect of RubyMotion and with some prompting from Stéphane Wirtel here is the issue and resolution including the code to make the iPhone speak.

Firstly setting up the app, assuming you've already copied the files you need into your vendor/iSpeechSDK directory this is the code needed in the rakefile as per any normal library ...

app.vendor_project('vendor/iSpeechSDK', :static, :products => ["libiSpeechSDK.a"], :headers_dir => "Headers")

@m14t
m14t / fix_github_https_repo.sh
Created July 5, 2012 21:57
Convert HTTPS github clones to use SSH
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi
@joerichsen
joerichsen / parallel_assets_compiler.gemspec
Created June 5, 2012 06:23
Microgem for compiling assets in parallel
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'parallel_assets_compiler'
s.version = '0.2.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jørgen Orehøj Erichsen'
s.email = 'joe@erichsen.net'
s.summary = 'Compile assets in parallel'
s.description = 'Compile assets in parallel to speed up deployment'
@thorn
thorn / get_url_params.js.coffee
Created May 23, 2012 13:14
getting url params with coffeescript and jquery
# Returns get parameters.
#
# If the desired param does not exist, null will be returned
#
# To get the document params:
# @example value = $(document).getUrlParam("paramName");
#
# To get the params of a html-attribut (uses src attribute)
# @example value = $('#imgLink').getUrlParam("paramName");
jQuery.fn.extend
@thbar
thbar / csv.rb
Created April 19, 2012 19:54
Ruby CSV pipe pretty-printer
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
Bundler.setup
require 'csv'
require 'awesome_print'
if STDIN.tty?
puts 'your_command | csv'
else
@thbar
thbar / README.MD
Created April 18, 2012 09:43
Ruby JSON pipe pretty-printer

A quick ruby command line to pretty-print piped json.

Usage

Put this somewhere in your path, with chmod +x, then:

curl http://myapp.com/stuff.json | json

@thbar
thbar / single_instance_windows.rb
Created March 27, 2012 14:25
Single instance check with ruby and windows
# context: I need to be reasonably sure that not two instances of a ruby script
# run at the same time, on Windows. What follows seems to work.
# tested on ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
def log(msg)
puts "#{$$} #{msg}"
end
def do_the_work_with_lock
@jasoncodes
jasoncodes / gist:1938675
Created February 29, 2012 06:59
Default `psql` to current Rails application
function __database_yml {
if [[ -f config/database.yml ]]; then
ruby -ryaml -rerb -e "puts YAML::load(ERB.new(IO.read('config/database.yml')).result)['${RAILS_ENV:-development}']['$1']"
fi
}
function psql
{
if [[ "$(__database_yml adapter)" == 'postgresql' ]]; then
PGDATABASE="$(__database_yml database)" "$(/usr/bin/which psql)" "$@"
@julien-duponchelle
julien-duponchelle / backup.sh
Created February 27, 2012 16:09
Dotcloud backup to S3 improved
#!/bin/bash
#
# Improved version of http://docs.dotcloud.com/guides/backups/
#
HOSTNAME=`hostname`
TAG="${HOSTNAME}_$(TZ=UTC date +%Y-%m-%d_%H:%M:%S_UTC)"
[ "$3" ] || {
echo "Please specify what to backup, how, and where."