Skip to content

Instantly share code, notes, and snippets.

View benoittgt's full-sized avatar
🏳️‍🌈

Benoit Tigeot benoittgt

🏳️‍🌈
View GitHub Profile
@benoittgt
benoittgt / gist:f67c0f7a9f361bb3613f
Created February 25, 2015 21:36
brew install postgresql 9.4.1 on OSX 10.6.8 & Homebrew 0.9.5
==> Downloading http://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2
Already downloaded: /Users/benoitpro/Library/Caches/Homebrew/postgresql-9.4.1.tar.bz2
==> Verifying postgresql-9.4.1.tar.bz2 checksum
tar xf /Users/benoitpro/Library/Caches/Homebrew/postgresql-9.4.1.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.4.1 --datadir=/usr/local/Cellar/postgresql/9.4.1/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.4.1/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-ldap --with-openssl --with-pam --with-libxml --with-libxslt --with-perl --with-tcl --with-uuid=e2fs
checking build system type... x86_64-apple-darwin10.8.0
checking host system type... x86_64-apple-darwin10.8.0
checking which template to use... darwin
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
@benoittgt
benoittgt / gist:187256cfe266f49c84ad
Created March 4, 2015 18:48
Geocoder behing QuotaGuard on Heroku
Running `rails console` attached to terminal... up, run.8280
Loading production environment (Rails 4.2.0)
irb(main):001:0> Geocoder.search("12 rue de Rivoli Paris")
Geocoder::ResponseParseError: Geocoder::ResponseParseError
from /app/vendor/bundle/ruby/2.0.0/gems/geocoder-1.2.7/lib/geocoder/lookups/base.rb:159:in `raise_error'
from /app/vendor/bundle/ruby/2.0.0/gems/geocoder-1.2.7/lib/geocoder/lookups/base.rb:186:in `rescue in parse_json'
from /app/vendor/bundle/ruby/2.0.0/gems/geocoder-1.2.7/lib/geocoder/lookups/base.rb:180:in `parse_json'
from /app/vendor/bundle/ruby/2.0.0/gems/geocoder-1.2.7/lib/geocoder/lookups/base.rb:193:in `parse_raw_data'
from /app/vendor/bundle/ruby/2.0.0/gems/geocoder-1.2.7/lib/geocoder/lookups/base.rb:169:in `fetch_data'
from /app/vendor/bundle/ruby/2.0.0/gems/geocoder-1.2.7/lib/geocoder/lookups/google.rb:28:in `results'
@benoittgt
benoittgt / benchmark_active_record_VS_sql.rb
Created August 14, 2015 08:16
Difference between active record and sql for with/without request
#In pry-rails on my rails project
require 'benchmark/ips'
Benchmark.ips do |x|
x.report("sql request") { User.where("EXISTS (SELECT 1 FROM groups_users WHERE groups_users.user_id = users.id AND groups_users.group_id IN (?))", [8939, 8950]).where("NOT EXISTS (SELECT 1 FROM groups_users WHERE groups_users.user_id = users.id AND groups_users.group_id IN (?))", [8942]).count
x.report("active record") { (User.joins(:groups).where(groups: {id: ["8939","8950"]}) - User.joins(:groups).where(groups: {id: 8942})).count }
x.compare!
end
# I have this code:
def destroy
old_store = mobile_application.store
users_ids = [1,2]
super
UpdateLastUpdatesWorker.perform_async old_store.id, users_ids
mobile_application.last_update = mobile_application.old_last_update
mobile_application.save!
require 'benchmark/ips'
require 'mail'
Benchmark.ips do |x|
x.report("'erger@log.com'.split('@')[1]") { 'erger@log.com'.split('@')[1] }
x.report("Mail::Address.new('erger@log.com').domain") { Mail::Address.new('erger@log.com').domain }
x.compare!
end
"status Vundle
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
call plug#begin('~/.vim/plugged')
" let Vundle manage Vundle, required
Plug 'gmarik/Vundle.vim'
Plug 'albfan/ag.vim'
@benoittgt
benoittgt / file1.txt
Created April 13, 2016 11:27
Created via API
Demo
@benoittgt
benoittgt / gist:f8fadd3482eabef7d45752a22f7323a9
Created October 7, 2016 14:05
Run rspec test on file change against dev branch
git diff --name-only --diff-filter=AMR origin/develop | grep _spec.rb | xargs bin/rspec

Keybase proof

I hereby claim:

  • I am benoittgt on github.
  • I am benoittgt (https://keybase.io/benoittgt) on keybase.
  • I have a public key whose fingerprint is A53D 31EF 53DE DCF9 19B7 062B 3D72 1D83 9FFF 5B74

To claim this, I am signing this object:

@benoittgt
benoittgt / build.sh
Created November 29, 2016 14:32
Create lambda per env
#!/bin/bash
set -e
version=`cat package.json | grep version | cut -d: -f2 | sed -e "s/\"//g" | sed -e "s/ //g" | sed -e "s/\,//g"`
function_name=stats_refresher
filename=$function_name-$version.zip
region=eu-west-1
envs=(int demo prod)
files_to_copy=( index.js package.json node_modules dist rds_config_from_env.js )