Skip to content

Instantly share code, notes, and snippets.

View byroot's full-sized avatar

Jean Boussier byroot

View GitHub Profile
@byroot
byroot / git-squash.sh
Created March 19, 2012 09:58
Git squash
#!/bin/bash -e
# Go back to the last commit that we want to form the initial commit (detach HEAD)
branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
tag="tmp-$RANDOM"
git checkout HEAD
# reset the branch pointer to the initial commit,
# but leaving the index and working tree intact.
git reset --soft HEAD~1
@byroot
byroot / eols.sh
Created March 27, 2012 15:08
Convert the whole git history with dos2unix
git filter-branch --tree-filter 'git ls-files -z | xargs -0 dos2unix' -- --all
import argparse
from pysrt import SubRipFile, SubRipItem, SubRipTime
parser = argparse.ArgumentParser(description='Merge 2 srt files.')
parser.add_argument('fin', type=str, nargs=2,
help='input file')
parser.add_argument(dest='fout', type=str, nargs=1,
help='the output file')
@byroot
byroot / select2-testcase.html
Created June 15, 2012 17:34
SHow a failing case with select2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Select2 2.1</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Select2 JQuery Plugin">
<meta name="author" content="Igor Vaynberg">
class Foo
module SomeObserver
extend ActiveSupport::Concern
included do
after_create :do_something
end
def do_something
#
end
module Raven
class Report < Tilt::Template
def prepare
end
def evaluate(context, locals, &block)
if context.logical_path.include?('raven') || context.logical_path.include?('github-integration')
data
else
desc "convert a latin1 database with utf8 data into proper utf8"
task :convert_to_utf8 => :environment do
puts Time.now
dryrun = ENV['DOIT'] != '1'
conn = ActiveRecord::Base.connection
if dryrun
def conn.run_sql(sql)
puts(sql)
end
else
@byroot
byroot / wtf.rb
Last active August 29, 2015 13:57
class Foo
def bar(*args)
attribute(:bar, *args)
end
def attribute(name)
puts name
end
if Rails::VERSION::MAJOR >= 4
if Rails::VERSION::MINOR > 0
ActiveSupport::Deprecation.warn("This patch is probably not useful anymore. Check if https://github.com/rails/rails/pull/12425 have been released.")
end
class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
def type_cast(value, column)
case value
when TrueClass