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.10.0) encoding benchmark (n=10) | |
--------------------------------------------- | |
Autodetect (indexed) 0.860000 0.000000 0.860000 ( 0.856220) | |
:no_compression 0.490000 0.000000 0.490000 ( 0.488724) | |
:fast_rgba 0.140000 0.000000 0.140000 ( 0.143066) | |
:fast_rgb 0.140000 0.000000 0.140000 ( 0.143170) | |
:good_compression 0.470000 0.010000 0.480000 ( 0.476883) | |
:best_compression 1.880000 0.000000 1.880000 ( 1.877189) |
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
~ $ request-log-analyzer production.log # Analyze production.log | |
--format custom_file_format.rb # Use custom file format | |
--reject account_type free # Ignore requests from free accounts | |
--select locale en-US # Only look at en-US locale requests | |
--output HTML --file report.html # Generate an HTML report as report.html |
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
#!/usr/bin/env ruby | |
# Converts an InnoDB database that uses a shared InnoDB tablespace file (e.g. ibdata1) to use | |
# a separate file per table. | |
# | |
# - First change your my.cnf file to use separate files by adding "innodb_file_per_table" to | |
# the [mysqld] section. (This is safe: MySQL will revert to the giant file if it cannot find | |
# the per table file.) | |
# - Restart the MySQL server | |
# - cd to the directory of your database (cd /opt/mysql/data/mydb) |
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 |
NewerOlder