This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# settings | |
@bucket_count = 1000 # Must be integer > 0 | |
@min_value = 10 ** -4 # Must be > 0.0 | |
@max_value = 10 ** +2 # Must be > @min_value | |
# precalculate some stuff | |
@min_value_log = Math.log(@min_value) | |
@max_value_log = Math.log(@max_value) | |
@log_delta = @max_value_log - @min_value_log | |
@bucket_size = @log_delta / @bucket_count.to_f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'chunky_png' | |
# get the data | |
data = StringIO.new(File.read('filename.bmp')) | |
bmp_file_header = data.read(14).unpack('a2VxxV') | |
bmp_info_header = data.read(40).unpack('V3v2V6') | |
raise "Not a BMP file" unless bmp_file_header[0] == "BM" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------------------------------- | |
ChunkyPNG (0.8.0) decoding benchmark (n=50) | |
--------------------------------------------- | |
Rehearsal --------------------------------------------------------- | |
From PNG stream 16.050000 0.110000 16.160000 ( 16.747523) | |
From RGBA pixelstream 0.090000 0.030000 0.120000 ( 0.122060) | |
From RGB pixelstream 0.860000 0.030000 0.890000 ( 0.901062) | |
----------------------------------------------- total: 17.170000sec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Swearing | |
SWEAR_WORDS = ['dammit', 'fuck', 'son of a bitch', 'motherfucker', 'oh no', 'prick'] | |
SWEAR_VOICE = 'Alex' | |
def self.swear! | |
`say -v #{SWEAR_VOICE} #{SWEAR_WORDS[rand(SWEAR_WORDS.length)]} &` | |
end | |
end | |
class Test::Unit::Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ParseTree | |
# Evaluates a static part of the tree that ParseTree.translate returns. | |
# You can pas a block that will be used to get a value that is not static. | |
# A simple example: | |
# | |
# >> code = '{ :array => ["str", 123, 4.5], :dynamic => method_call }' | |
# >> tree = ParseTree.translate(code) | |
# => [:hash, [:lit, :array], [:array, [:str, "str"], [:lit, 123], [:lit, 4.5]], | |
# [:lit, :dynamic], [:vcall, :method_call]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# colors for ls, etc. | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/' | |
} | |
if [[ ${EUID} == 0 ]] ; then | |
PS1='\[\033[01;31m\]\u@\h \[\033[01;34m\]\w\[\033[01;35m\]$(parse_git_branch)\[\033[01;34m\] \$ \[\033[00m\]' | |
else | |
PS1='\[\033[01;37m\]\w\[\033[00;35m\]$(parse_git_branch)\[\033[00m\] \$ ' | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
____ ____ ____ _______ | |
| | | _/ | |
| | | \o/ _/ | |
| | | | _/ | |
| | ==> | /\/ | |
| o | | _/ | |
| |- | | _/ | |
|_/\_| |____/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: confluent/kafka/* confluent/zookeeper/* confluent/registry/* confluent/start confluent/stop | |
# Confluent platform tasks | |
confluent/start: confluent/rest/start | |
confluent/stop: confluent/rest/stop confluent/registry/stop confluent/kafka/stop confluent/zookeeper/stop | |
# Download & extract tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There must be a nicer way than this | |
((x & 0xf00) << 12 | (x & 0xf00) << 8) | | |
((x & 0x0f0) << 8 | (x & 0x0f0) << 4) | | |
((x & 0x00f) << 4 | (x & 0x00f)) |
NewerOlder