Skip to content

Instantly share code, notes, and snippets.

View elhu's full-sized avatar

Vincent Boisard elhu

View GitHub Profile
package main
import (
"database/sql"
"fmt"
"github.com/Sereal/Sereal/Go/sereal"
_ "github.com/go-sql-driver/mysql"
"io/ioutil"
"os"
"strings"
@elhu
elhu / keybase.md
Created January 12, 2017 21:09
keybase.md

Keybase proof

I hereby claim:

  • I am elhu on github.
  • I am elhu (https://keybase.io/elhu) on keybase.
  • I have a public key whose fingerprint is 7AB7 DFD7 C4FA A954 D862 E0CF EF0D A9A9 F9BD 3296

To claim this, I am signing this object:

@elhu
elhu / app.rb
Last active February 11, 2016 11:18 — forked from archiloque/app.rb
Example of logging queries
require 'sinatra/base'
require 'sequel'
require 'logger'
# Add hooks in sequel logging since it's called for each query
module Sequel
class Database
# Alias a method so we can override it but still call the original
alias :log_yield_old :log_yield
@elhu
elhu / Gemfile
Last active January 4, 2016 00:19
ruby-band basic
source 'https://rubygems.org'
gem 'sinatra'
gem 'ruby-band'
@elhu
elhu / wrong argument type Proc (expected Proc)
Last active December 23, 2015 21:59
Errors occurring on Passenger 4 Enterprise 4.0.14
Backtrace:
On line #20 of app/views/layouts/application.html.erb
17: <%= execute_extensions_view_method :head %>
18: <%= custom_head_section %>
19: </head>
20: <% body_tag do %>
21: <%= admin_toolbar %>
22: <%= header %>
23: <% deprecated_doc4 yield(:document_class_for_sidebar) || 'yui-t7' do %>
@elhu
elhu / gist:5806022
Created June 18, 2013 14:52
Ferret with ruby 2.0.0p195
jenkins@ci [ideas_feature_remove-iconv] > gem install ferret
Building native extensions. This could take a while...
ERROR: Error installing ferret:
ERROR: Failed to build gem native extension.
/var/lib/jenkins/.rbenv/versions/2.0.0-p195/bin/ruby extconf.rb
creating Makefile
make
compiling STEMMER_stem_ISO_8859_1_dutch.c
@elhu
elhu / java1:elasticsearch.yml
Last active December 18, 2015 15:39
ElasticSearch unicast discovery problem
# from java1
cluster.name: dimelo
network.bind_host: 0.0.0.0
network.publish_host: 10.10.4.8
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["java1.dimelo:9200", "java2.dimelo:9200"]
# Setup step
stub(Version.just_updated).paginate(:page => nil, :per_page => 50){ [@version_2, @version_3, @version_4] }
stub(Version.just_updated).paginate(:page => 2, :per_page => 50){ [@version_4, @version_3, @version_2] }
stub(Version.just_updated).paginate do |args|
raise args.inspect
end
# Test
should "raise an exception" do
pp Version.just_updated.paginate(:page => 3, :per_page => 50) #=> []
@elhu
elhu / gist:4065174
Created November 13, 2012 10:48
MongoDB question
class Band
include Mongoid::Document
store_in collection: "artists", database: "music", session: "secondary"
end
class BandsController < ApplicationController
before_filter :switch_database
after_filter :reset_database
private
@elhu
elhu / gist:3973143
Created October 29, 2012 11:50
Method missing with module
def method_missing(method, *args, &block)
begin
super
rescue NoMethodError => e
warn("Warning: Unknown field or method #{method} for object #{self.inspect}\nBacktrace:\n#{e.backtrace.join("\n")}")
end
end