Skip to content

Instantly share code, notes, and snippets.

View dx7's full-sized avatar

Rafael Almeida de Carvalho dx7

View GitHub Profile
@dx7
dx7 / base16.rb
Created May 13, 2021 21:49 — forked from sspreitzer/base16.rb
ruby base16
# Ruby base16 encode/decode
# (c) Sascha Spreitzer, 2016
# MIT license
def b16decode(what)
chars = ''
ret = ''
what.each_char do |c|
chars += c
if chars.size == 2
#!/usr/bin/env bash
set -e
addEntries() {
# check if universal access / custom menu key exists
if defaults read com.apple.universalaccess com.apple.custommenu.apps > /dev/null 2>&1; then
defaults delete com.apple.universalaccess com.apple.custommenu.apps
fi
@dx7
dx7 / ruby_data_object_comparison.rb
Created April 15, 2020 18:47 — forked from palexander/ruby_data_object_comparison.rb
Benchmark to compare hash, OpenStruct, struct, and classes in Ruby
require 'ostruct'
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "test@example.org"
class Person
attr_accessor :name, :email
end
@dx7
dx7 / Gemfile
Last active August 29, 2015 14:06 — forked from hubertlepicki/Gemfile
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 4.0"
gem "railties", "~> 4.0"
gem "tzinfo"
# Let's use thin
@dx7
dx7 / guitar.rb
Created November 2, 2012 15:37 — forked from caike/guitar.rb
update attribute
# update_attribute
guitar.update_attribute(:state, 'used')
# method on model
class Guitar
def mark_as_used
self.state = 'used'
self.save
@dx7
dx7 / gist:1083894
Created July 15, 2011 02:03 — forked from rodrigotassinari/gist:1078666
Patched Ruby 1.9.2 for faster load and GC
# Just run:
# bash < <(curl -Ls https://raw.github.com/gist/1083894)
# Update and cleanup RVM
rvm get head
rvm reload
rvm cleanup all
# Ruby 1.9 Fast require:
# https://gist.github.com/1008945
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
aula. Ele pratica. Instrumentistas geniais nao aprendem a tocar tendo
aula. Eles praticam. Pratique. Chegue em casa depois do trabalho e da