Skip to content

Instantly share code, notes, and snippets.

View lleirborras's full-sized avatar
💭
Not much

Lleïr Borràs Metje lleirborras

💭
Not much
View GitHub Profile
### Keybase proof
I hereby claim:
* I am lleirborras on github.
* I am lleirborras (https://keybase.io/lleirborras) on keybase.
* I have a public key ASD9MAsbcx9L31EtnxD4YgZfdqcXXqdvf-vytbAIlIb_7Qo
To claim this, I am signing this object:
class Collectd < Formula
desc "Statistics collection and monitoring daemon"
homepage "https://collectd.org/"
stable do
url "https://collectd.org/files/collectd-5.7.1.tar.bz2"
sha256 "7edd3643c0842215553b2421d5456f4e9a8a58b07e216b40a7e8e91026d8e501"
end
bottle do
#!/usr/bin/env ruby
require 'etc'
require 'cgi'
require 'open-uri'
require 'nokogiri'
message = "@lleirborras is comitting "
message << Nokogiri.parse(open("http://whatthecommit.com").read).css('#content p').first.text.strip
### Keybase proof
I hereby claim:
* I am lleirborras on github.
* I am lleirborras (https://keybase.io/lleirborras) on keybase.
* I have a public key whose fingerprint is 09F3 CE74 326F 0986 0C03 E7FC FCFC 477B 42BB ADA2
To claim this, I am signing this object:
@lleirborras
lleirborras / swaplines.vim
Created February 25, 2014 10:51
Vim/Mvim/Gvim/NeoVim macro to swap lines with shift-[up | down]
function! s:swap_lines(n1, n2)
let line1 = getline(a:n1)
let line2 = getline(a:n2)
call setline(a:n1, line2)
call setline(a:n2, line1)
endfunction
function! s:swap_up()
let n = line('.')
if n == 1
@lleirborras
lleirborras / couchdb-lucene-build.rb
Last active December 20, 2015 15:38
CouchDB Lucene Build Brew Formula
require 'formula'
class CouchdbLuceneBuild < Formula
homepage 'https://github.com/ifad/couchdb-lucene-build'
url 'https://github.com/ifad/couchdb-lucene-build/archive/master.tar.gz'
version '0.0.1'
depends_on 'couchdb'
depends_on 'maven'
# This allows to use a numeric or a lambda
def retry_upto(max_retries = 1, options = {})
begin
return yield if ((max_retries -= 1) > 0)
rescue (options[:rescue_only] || Exception)
options[:wait] = if options[:patience].is_a?(Numeric)
options[:wait] * options[:patience]
else
options[:patience].call(options[:wait])
# Ruby `retry` with steroids:
#
# - retry up to 5 times without waiting between them and retrying after any exception
#
# retry_upto(5) do ... end
#
# - retry up to 5 times, waiting 2 seconds between retries and retrying after any exception
#
# retry_upto(5, :wait => 2) do ... end
#
# Ruby `retry` with steroids:
#
# - retry up to 5 times without waiting between them and retrying after any exception
#
# retry_upto(5) do ... end
#
# - retry up to 5 times, waiting 2 seconds between retries and retrying after any exception
#
# retry_upto(5, :wait => 2) do ... end
#
module Mod
def self.included(base)
base.class_eval do
puts "Included in #{base}"
p ObjectSpace.each_object(Class).sort{|a,b| a.name <=> b.name}.select{|a| a.superclass == Person}.uniq.size
end
end
end