Skip to content

Instantly share code, notes, and snippets.

@eraserewind
eraserewind / prout.md
Last active March 8, 2017 11:40
{topo,geos} vs. {hipe,beam} vs. {atom,xeon}

tl;dr

build   cpu    benchmark name                               iterations   average time
BEAM   Xeon   Topo.contains?(@north_america, @usa)                100   14693.69 µs/op 
HiPE   Xeon   Topo.contains?(@north_america, @usa)                100   11093.37 µs/op -3600.319
C      Xeon   GEOS.contains(@north_america, @usa)            10000000   0.19 µs/op     -14693.5

BEAM   Xeon   Topo.contains?(@north_america, @russia)             100   26424.66 µs/op
HiPE   Xeon   Topo.contains?(@north_america, @russia)             100   17096.10 µs/op  -9328.560
### Keybase proof
I hereby claim:
* I am eraserewind on github.
* I am jbracco (https://keybase.io/jbracco) on keybase.
* I have a public key whose fingerprint is 8891 E1E7 26CC 8030 4B84 885A E89A 181D 331D 2B12
To claim this, I am signing this object:
@eraserewind
eraserewind / onlinenet_debian_ipv6.md
Last active October 24, 2021 03:47
Online.net: IPv6 in Debian virtual machines

Online.net: IPv6 in Debian virtual machines

Without this annoying dribbler thing.

Variables

  • RANGE = /64
  • EXT_IF = external interface
  • IPV6 = Any IPv6 in RANGE
  • DUID = dhcp client id. Find it in console.online.net
begin
wait_for_miracle do |miracle|
return miracle.proof_that_god_exists
end
rescue Timeout::Error => e
return e.proof_that_god_exists
end
@eraserewind
eraserewind / programme-tv.css
Last active August 29, 2015 14:04
programme-tv.net css fix.
#videoPush { display:none }
#newsPush { display:none }
#sidebar { display:none }
#header { display:none }
#col_left { width: 100% }
.channel .programme .readmore { display:none }
.block.sondages { display:none }
.baseline, .footer-layout, .sf-extensionfactory-link { display:none }
@eraserewind
eraserewind / free-mobile-sms.zsh
Last active August 29, 2015 14:02
Send SMS to yourself using Free Mobile's SMS notifications API.
FREE_MOBILE_SMS_USER="..."
FREE_MOBILE_SMS_PASS="..."
function self-sms {
setopt extendedglob
encoded="${${(j: :)@}//(#b)(?)/%$[[##16]##${match[1]}]}"
curl -q https://smsapi.free-mobile.fr/sendmsg\?user\=${FREE_MOBILE_SMS_USER}\&pass\=${FREE_MOBILE_SMS_PASS}\&msg\=${encoded}
}
# self-sms hello my friend how are you\?
iex(1)> rec = :erl_img.load("/tmp/img.01052272347D8C5DA78E655299E8176")
{:ok,
{:erl_image, :image_gif, :undefined,
"/tmp/img.01052272347D8C5DA78E655299E8176", :undefined, :undefined,
:undefined, :undefined, [], :palette8, 400, 212, 8, 3, 1,
[ApplicationIdentifier: 'XMP Data', ApplicationAuthenticationCode: 'XMP',
ApplicationData: <<63, 120, 112, 97, 99, 107, 101, 116, 32, 98, 101, 103, 105, 110, 61, 34, 239, 187, 191, 34, 32, 105, 100, 61, 34, 87, 53, 77, 48, 77, 112, 67, 101, 104, 105, 72, 122, 114, 101, 83, 122, 78, 84, 99, 122, 107, 99, 57, 100, 34, ...>>,
ApplicationIdentifier: 'NETSCAPE', ApplicationAuthenticationCode: '2.0',
ApplicationData: <<1, 0, 0>>, Background: 255, AspectRatio: 0, Sort: 0],
:left_to_right,
iex(22)> exif
[JPEGInterchangeFormatLength: [7164], JPEGInterchangeFormat: [862],
ResolutionUnit: [2], YResolution: [{72, 1}], XResolution: [{72, 1}],
Compression: [6], Software: ['Adobe Photoshop CS4 Macintosh'],
ResolutionUnit: [2], YResolution: [{2400000, 10000}],
XResolution: [{2400000, 10000}], Orientation: [1], Model: ['NIKON D80'],
Make: ['NIKON CORPORATION']]
iex(23)> JSON.encode(exif)
** (ArgumentError) argument error
:erlang.apply(72, :to_keywords, [])
irb(main):023:0> Device.find_by_index('ident', '42942424242')
Zlib::DataError: incorrect header check
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http/response.rb:357:in `finish'
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http/response.rb:357:in `finish'
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http/response.rb:262:in `ensure in inflater'
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http/response.rb:262:in `inflater'
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http/response.rb:274:in `read_body_0'
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http/response.rb:201:in `read_body'
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http/response.rb:226:in `body'
from /Users/j/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/riak-client-1.0.5/lib/riak/client/net_http_backend.rb:58:in `block (2 levels) in perform'
@eraserewind
eraserewind / bootstrap_horizontal_form.rb
Created July 28, 2013 19:08
bootstrap 3 horizontal form rails builder
class BootstrapHorizontalForm < ActionView::Helpers::FormBuilder
def text_field(method, options={})
width = options[:width] || 10
t = @template
t.content_tag(:div, :class => "form-group#{' has-error' unless @object.errors[method].blank?}") {
t.concat(t.label(@object_name, method, class: 'col-lg-2 control-label'))
t.concat(t.content_tag(:div, class: "col-lg-#{width}") {
t.concat(t.text_field(@object_name, method, options.merge(class: 'form-control')))
if @object.errors[method].present?