Skip to content

Instantly share code, notes, and snippets.

View franckverrot's full-sized avatar
📚
🥋

Franck Verrot franckverrot

📚
🥋
View GitHub Profile
@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.
@franckverrot
franckverrot / Makefile
Created February 4, 2014 08:22
Rake and Make, for very very simple needs
default: test
test:
ruby "test/unittest.rb"
module elmira
import java.util.HashMap
import java.util.Arrays
import java.util.LinkedList
function test = -> DynamicObject()
function Elmira = -> DynamicObject():
@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
@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 / 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" } }
~/Development/git 32deca7 [±] λ git lock
usage: git lock <file>
---------------------------------------------------------------
|Owner |Locked file |
---------------------------------------------------------------
|franckverrot |foo |

The easiest way to start using the LLVM C++ API by example is to have LLVM generate the API usage for a given code sample. In this example it will emit the code required to rebuild the test.c sample by using LLVM:

$ clang -c -emit-llvm test.c -o test.ll
$ llc -march=cpp test.ll -o test.cpp
require 'benchmark/ips'
class Foo
def bar
# "Foo#bar"
end
end
module Bar
def bar
@franckverrot
franckverrot / test.rb
Created March 12, 2015 21:40
||= and &&= don't complain the same way
irb(main):001:0> $-w = true
=> true
irb(main):002:0> @foo ||= true
=> true
irb(main):003:0> @bar &&= true
(irb):3: warning: instance variable @bar not initialized
=> nil