Skip to content

Instantly share code, notes, and snippets.

View franckverrot's full-sized avatar
📚
🥋

Franck Verrot franckverrot

📚
🥋
View GitHub Profile
~/Development/git 32deca7 [±] λ git lock
usage: git lock <file>
---------------------------------------------------------------
|Owner |Locked file |
---------------------------------------------------------------
|franckverrot |foo |
@franckverrot
franckverrot / test.rb
Last active August 29, 2015 14:01
String#<< vs String#+=
# More details about the 23 value
# https://github.com/ruby/ruby/blob/e279eca4bdf1e4364308aee2ca504bbdf2b5d221/include/ruby/ruby.h#L824-836
#
require 'benchmark'
N = 1_000_000
Benchmark.bmbm do |bm|
bm.report("s_23chr +=") { N.times { s_23chr = "xxxxxxxxxxxxxxxxxxxxxx"; s_23chr += "x" } }
bm.report("s_23chr <<") { N.times { s_23chr = "xxxxxxxxxxxxxxxxxxxxxx"; s_23chr << "x" } }
@franckverrot
franckverrot / hiredis.log
Last active August 29, 2015 14:01
hiredis test
/private/tmp/hiredis-rb 691a320 [±] λ rake compile && RUBYLIB=lib ruby -rhiredis test.rb
cd tmp/x86_64-darwin13.0/hiredis_ext/2.1.0
make
compiling ../../../../ext/hiredis_ext/connection.c
linking shared-object hiredis/ext/hiredis_ext.bundle
cd -
install -c tmp/x86_64-darwin13.0/hiredis_ext/2.1.0/hiredis_ext.bundle lib/hiredis/ext/hiredis_ext.bundle
[connection_is_connected is called]
true
nil
@franckverrot
franckverrot / example.rb
Created May 2, 2014 20:51
Message-passing, layers and SRP
class InviteController < ApplicationController
# The controller's responsibility is to build an object graph
# that will do the hard work.
def accept
response = InvitationResponse.new(self)
scenario = InvitationScenario.new(response)
scenario.accept_invite_token_for_user(current_user, params[:token])
# The alternative is to implement both
module elmira
import java.util.HashMap
import java.util.Arrays
import java.util.LinkedList
function test = -> DynamicObject()
function Elmira = -> DynamicObject():
@franckverrot
franckverrot / Makefile
Created February 4, 2014 08:22
Rake and Make, for very very simple needs
default: test
test:
ruby "test/unittest.rb"
@franckverrot
franckverrot / .netrc dance
Created February 3, 2014 12:41
Using multiple .netrc files. FWIW, I store my .netrc files in some specific folders.
franck@zeu ~ % HOME=.ssh/heroku-franck heroku apps
=== My Apps
...
=== Collaborated Apps
[redacted]
franck@zeu ~ % HOME=.ssh/heroku-evome heroku apps
You have no apps.
gem "paymill"
@franckverrot
franckverrot / gist:4749663
Created February 10, 2013 13:57
Remove emojis front GitHub's textareas.
//Paste the line below in your URL address bar to disable emojis
// This line only works on new Issues.
javascript:;jQuery('#issue_body').replaceWith($('<div name="issue[body]"/>').html('')); jQuery('[name="issue[body]"]').replaceWith($('<textarea name="issue[body]"/>').html(''));
require "./tinyparse"
parser = Tinyparse.build do
paren "(", :main, ")", :main
main [:paren, ""]
end
["((()))", "(((", "()()((()()))", "))(("].each do |str|
puts str