Skip to content

Instantly share code, notes, and snippets.

View changa's full-sized avatar

Dominique Rose-Rosette changa

  • Praditus
  • Paris, France
View GitHub Profile
$ sudo vim /etc/systemd/system/docker-compose.service
[Unit]
Description=DockerCompose
After=docker.service
Requires=docker.service
[Service]
ExecStart=/opt/bin/docker-compose -f /home/core/docker-compose.yml up -d
@changa
changa / ipcat.ruby
Last active December 1, 2015 11:24
IP ranges directory
#!/usr/bin/env ruby
require "ipaddr"
module IPCat
class Datacenter
attr_reader :range, :name, :url
def initialize(start_addr, end_addr, name, url = nil)
@changa
changa / wtf
Created November 21, 2014 17:41
Strange ActiveSupportDuration behaviour
$ bundle exec rails console
2.1.2 (main):0 > now = Time.now; now - 1.minute == now - Integer(1.minute)
=> true
2.1.2 (main):0 > now = Time.now; now - 1.month == now - Integer(1.month)
=> false # WTF!
2.1.2 (main):0 > 1.month == Integer(1.month)
=> true
@changa
changa / git-wip
Last active August 29, 2015 14:01
Git-wip : git stash straight to a dedicated branch
#!/bin/sh
# vim: set ft=sh :
if [ $# -ne 1 ]; then
echo "List of WIP branches:"
git branch|grep -e '^wip_'
else
if [ -z "$(git ls-files)" ]; then
echo "No files to stash in the staging area" >&2
exit 1
@changa
changa / locks.sql
Created April 10, 2014 14:20
Show current locks (for PosgreSQL < 9.2)
-- Taken from http://wiki.postgresql.org/wiki/Lock_Monitoring
-- (PostgreSQL < 9.2 version)
SELECT bl.pid AS blocked_pid,
a.usename AS blocked_user,
ka.current_query AS blocking_statement,
now() - ka.query_start AS blocking_duration,
kl.pid AS blocking_pid,
ka.usename AS blocking_user,
a.current_query AS blocked_statement,
now() - a.query_start AS blocked_duration
@changa
changa / gist:4761918
Created February 12, 2013 12:11
${HOME}/.pryrc
# vim: se ft=ruby :
# ${HOME}/.pryrc
# https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
if defined?(::Bundler) || File.exists?('Gemfile')
global_gemset = ENV['GEM_PATH'].split(':').grep(%r{ruby.*@global|gemsets/global}).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
@changa
changa / .gitconfig
Last active October 11, 2015 07:58
$HOME/.gitconfig
# vim: se ft=gitconfig :
[diff]
color = true
[alias]
; shortcuts
st = status
a = add
ap = add -p
@changa
changa / .pryrc
Created June 15, 2012 14:19
Pryrc stuff
# vim: se ft=ruby :
# https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
if defined?(::Bundler) || File.exists?('Gemfile')
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
$LOAD_PATH << gem_path
@changa
changa / gist:1234795
Created September 22, 2011 13:41
ldd jasmine-webkit-specrunner
1.9.2@global|drr@drr-x201:~/.rvm/gems/ruby-1.9.2-p180-patched@ftv/gems/jasmine-headless-webkit-0.7.1 $ ldd ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner
linux-vdso.so.1 => (0x00007ffff97ff000)
libQtWebKit.so.4 => /usr/lib/libQtWebKit.so.4 (0x00007fcf562f5000)
libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0x00007fcf55615000)
libQtNetwork.so.4 => /usr/lib/libQtNetwork.so.4 (0x00007fcf552d4000)
libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007fcf54e2f000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fcf54c13000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fcf54908000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcf54686000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcf54470000)
@changa
changa / gist:1183434
Created August 31, 2011 12:37
jasmine-headless-webkit backtrace
/home/drr/.rvm/rubies/ruby-1.9.2-p180-patched/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:553:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension ext/jasmine-webkit-specrunner/extconf.rb. (#<ArgumentError: invalid byte sequence in UTF-8>) (Gem::Installer::ExtensionBuildError)
/home/drr/.rvm/rubies/ruby-1.9.2-p180-patched/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:20:in `gsub'
/home/drr/.rvm/rubies/ruby-1.9.2-p180-patched/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:20:in `make'
/home/drr/.rvm/rubies/ruby-1.9.2-p180-patched/lib/ruby/site_ruby/1.9.1/rubygems/ext/ext_conf_builder.rb:18:in `build'
/home/drr/.rvm/rubies/ruby-1.9.2-p180-patched/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:532:in `block (2 levels) in build_extensions'
/home/drr/.rvm/rubies/ruby-1.9.2-p180-patched/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:531:in `chdir'
/home/drr/.rvm/rubies/ruby-1.9.2-p180-patched/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:531:in `block in build_extensions'
/