Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafael Almeida de Carvalho dx7

View GitHub Profile
View base16.rb
module Base16
def self.strict_encode16(s)
s.unpack1('H*')
end
def self.strict_decode16(s)
[s].pack('H*')
end
end
@dx7
dx7 / base16.rb
Created May 13, 2021 — forked from sspreitzer/base16.rb
ruby base16
View base16.rb
# 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
View add-macos-keyboard-shortcuts
#!/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 Apr 15, 2020 — forked from palexander/ruby_data_object_comparison.rb
Benchmark to compare hash, OpenStruct, struct, and classes in Ruby
View ruby_data_object_comparison.rb
require 'ostruct'
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "test@example.org"
class Person
attr_accessor :name, :email
end
View gist:d99e56a06cc4f4394688475e6d36bd33
[
{
"target": "timeShift(player_data.vod.player._metrics.audience, -10min)",
"datapoints": [
[
83739,
1532055000
]
]
}
@dx7
dx7 / tinyproxy.rb
Last active Aug 29, 2015
Tinyproxy: Formula to install from HEAD
View tinyproxy.rb
require 'formula'
class Tinyproxy < Formula
homepage "https://www.banu.com/tinyproxy/"
url "https://www.banu.com/pub/tinyproxy/1.8/tinyproxy-1.8.3.tar.bz2"
sha1 "2538fbd190d3dc357a2e7c2a07ea0fbefb768a13"
head do
url "https://github.com/dx7/tinyproxy.git", :branch => "1.8"
depends_on "autoconf" => :build
View 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
View media-info.rb
require 'formula'
class MediaInfo < Formula
homepage 'http://mediainfo.sourceforge.net'
url 'http://mediaarea.net/download/binary/mediainfo/0.7.67/MediaInfo_CLI_0.7.67_GNU_FromSource.tar.bz2'
version '0.7.67'
# sha1 'e5bfc3af8d3a0995785f1963c78ff9a6505e9626'
sha1 'e4b939c7d04ba52be679bcfd577905b65f6c72c6'
head 'svn://svn.code.sf.net/p/mediainfo/code'
@dx7
dx7 / gist:9424562
Created Mar 8, 2014
Ternário do stdio.h
View gist:9424562
/*
* This has been tuned to generate reasonable code on the vax using pcc.
*/
#define __sputc(c, p) \
(--(p)->_w < 0 ? \
(p)->_w >= (p)->_lbfsize ? \
(*(p)->_p = (c)), *(p)->_p != '\n' ? \
(int)*(p)->_p++ : \
__swbuf('\n', p) : \
__swbuf((int)(c), p) : \
View keybase.md

Keybase proof

I hereby claim:

  • I am dx7 on github.
  • I am dx7 (https://keybase.io/dx7) on keybase.
  • I have a public key whose fingerprint is 35FE C788 27E0 0669 564A 6228 85FE F453 4D62 6DC2

To claim this, I am signing this object: