Skip to content

Instantly share code, notes, and snippets.

View srpouyet's full-sized avatar

Sebastiaan Pouyet srpouyet

View GitHub Profile
@srpouyet
srpouyet / fabfile.py
Created June 27, 2012 19:54 — forked from cyberdelia/fabfile.py
Fabric deploy script with : south migrations, rollback and maintenance page.
from fabric.api import env, run, sudo, local, put
def production():
"""Defines production environment"""
env.user = "deploy"
env.hosts = ['example.com',]
env.base_dir = "/var/www"
env.app_name = "app"
env.domain_name = "app.example.com"
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name }
@srpouyet
srpouyet / ctags_autocomplete.py
Created July 19, 2012 08:07 — forked from BlackMac/ctags_autocomplete.py
autocomplete over project for Sublime Text 2
# CTags based autocompletion plugin for Sublime Text 2
# You can add the file to the User Package in ~/Library/Application Support/Sublime Text 2/Packages and restart Sublime Text 2.
# generate the .tags file in your project root with "ctags -R -f .tags"
import sublime, sublime_plugin, os
class AutocompleteAll(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
tags_path = view.window().folders()[0]+"/.tags"
@srpouyet
srpouyet / stringit.rb
Created October 29, 2012 19:23
Functional programming babysteps :)
# Functional programming babysteps :)
# This Proc returns a "stringified" version of the object you passed it.
# Example:
#
# h = Hash[1,2,3,4,5,[8,9,{:age => 90},[[[[60,{"a" => "gho"}]]],{[:what, 0] => [4.0 => 88.7]}]]]4.0 => 88.7]}]]]
# => {1=>2, 3=>4, 5=>[8, 9, {:age=>90}, [[[[60, {"a"=>"gho"}]]], {[:what, 0]=>[{4.0=>88.7}]}]]}
# stringit[h]
#=> {"1"=>"2", "3"=>"4", "5"=> ["8","9",{"age"=>"90"},[[[["60", {"a"=>"gho"}]]], {["what", "0"]=>[{"4.0"=>"88.7"}]}]]}
stringit = Proc.new do |v|
@srpouyet
srpouyet / .bash_login
Created November 1, 2012 13:52 — forked from jasoncodes/gist:1223731
Installing Ruby 1.9.3 with rbenv
# ~/.bash_login
export PATH="/usr/local/bin:$PATH"
@srpouyet
srpouyet / create_related_users.rb
Last active November 2, 2019 03:05
Self referential HABTM (has_and_belongs_to_many) in Rails 3

h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)

h2. General

  • ⌘T go to file
  • ⌘⌃P go to project
  • ⌘R go to methods
  • ⌃G go to line
  • ⌘KB toggle side bar
  • ⌘⇧P command prompt
@srpouyet
srpouyet / fix-nokogiri-libxml-warnings-mountain-lion.markdown
Last active December 14, 2015 14:18 — forked from devpuppy/nokogiri libxml homebrew lion
Get rid of those pesky "WARNING: Nokogiri was built against LibXML version X, but has dynamically loaded Z" warnings on Mac OS X (Mountain) Lion.

How to get rid of those pesky
WARNING: Nokogiri was built against LibXML version X, but has dynamically loaded Z
warnings on Mac OS X (Mountain) Lion:

  1. gem uninstall nokogiri libxml-ruby
    Continue to step 5 if you already recently brewed libxml2 and libxslt...
  2. brew update
  3. brew install libxml2 --with-xml2-config
  4. brew install libxslt
  5. gem install nokogiri -- --with-xml2-include=/usr/local/opt/libxml2/include --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xslt-dir=/usr/local/opt/libxslt
@srpouyet
srpouyet / active_link_to.rb
Last active December 15, 2015 14:39
Rails 3 active class navigation helper which by default takes query params into account.
# include from an initializer
module HstoreAccessor
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|
@srpouyet
srpouyet / restore_ipkg_and_rdiff_on_dsm.md
Last active December 19, 2015 05:29
How to restore IPKG and rdiff-backup after updating Synology DSM 4 to a new version.
  1. ssh in to your Synology
  2. $ vi /root/.profile
  3. prepend /opt/bin:/opt/sbin: to PATH so it looks like PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
    replace the standard rdiff packages with symlinks:
  4. $ ln -s /opt/bin/rdiff-backup-2.6 /usr/bin/rdiff-backup
  5. $ ln -s /opt/bin/rdiff-backup-statistics-2.6 /usr/bin/rdiff-backup-statistics