This file contains hidden or 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
SELECT | |
category, | |
segment, | |
SUM(exposures) AS exposures, | |
SUM(impressions)/(SUM(exposures) - SUM(indeterminate_visibility)) AS impression_rate, | |
SUM(engagements)/SUM(exposures) AS engagement_rate | |
FROM ( | |
SELECT | |
date, | |
ad_id, |
This file contains hidden or 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
~% rvm --trace wrapper 1.8.7@wukong wukong 15:19 reventon | |
+__rvm_parse_args:414> [[ -z 4.3.9 ]] | |
+__rvm_parse_args:570> [[ -z '' && -n '' ]] | |
+__rvm_parse_args:572> [[ 0 -eq 1 || -n '' ]] | |
+__rvm_parse_args:15> [[ -n wrapper ]] | |
+__rvm_parse_args:17> rvm_token=wrapper | |
+__rvm_parse_args:19> [[ 2 -gt 0 ]] | |
+__rvm_parse_args:19> next_token=1.8.7@wukong | |
+__rvm_parse_args:19> shift | |
+__rvm_parse_args:21> case wrapper (fetch|version|srcdir|reset|debug|reload|update|monitor|notes|implode|seppuku|question|answer|env) |
This file contains hidden or 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
~% cat .rvm/bin/wukong_\ 15:21 reventon | |
#!/usr/bin/env bash | |
if [[ -s "/Users/theo/.rvm/environments/ruby-1.8.7-p302@wukong" ]] ; then | |
\. "/Users/theo/.rvm/environments/ruby-1.8.7-p302@wukong" | |
exec "$@" | |
else | |
echo "ERROR: Missing RVM environment file: '/Users/theo/.rvm/environments/ruby-1.8.7-p302@wukong'" >&2 | |
exit 1 | |
fi |
This file contains hidden or 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 | |
require 'zlib' | |
require 'open-uri' | |
require 'json' | |
io = Zlib::GzipReader.new(open("http://api.stackoverflow.com/1.0/questions?tagged=redis&sort=votes&min=1")) | |
obj = JSON.parse(io.read) |
This file contains hidden or 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
Result of running bm.rb four times (which runs 100K iterations of encode or decode | |
over a set of values), taking the "user" column from the results: | |
+------------------+--------+---------+---------+---------+---------+ | |
| | Method | 1st run | 2nd run | 3rd run | 4th run | | |
+------------------+--------+---------+---------+---------+---------+ | |
| Baseline | Decode | 1.92 | 1.92 | 1.94 | 2.22 | | |
| | Encode | 1.90 | 1.91 | 1.91 | 1.92 | | |
+------------------+--------+---------+---------+---------+---------+ | |
| Constant Strings | Decode | 2.07 | 1.81 | 1.82 | 1.84 | |
This file contains hidden or 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
% brew install -vd imagemagick | |
/usr/local/bin/git | |
==> Cloning git://github.com/adamv/ImageMagick.git | |
Updating /Users/theo/Library/Caches/Homebrew/imagemagick--git | |
git fetch git://github.com/adamv/ImageMagick.git | |
From git://github.com/adamv/ImageMagick | |
* branch HEAD -> FETCH_HEAD | |
==> Checking out ref fdb125591a17a4002798742014118d5cfee44394 | |
git checkout-index -a -f --prefix=/private/tmp/homebrew-imagemagick-6.6.7-10-dXf5/ | |
==> ./configure --disable-osx-universal-binary --without-perl --prefix=/usr/local/Cellar/imagemagick/6.6.7-10 --disable-dependency-tracking --enable-shared --disable-static --with-modules --without-gslib --without-magick-plus-plus |
This file contains hidden or 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 'mongo' | |
mongo = Mongo::Connection.new | |
db = mongo.db('test') | |
collection = db.collection('helloworld') | |
collection.remove | |
collection.insert({:x => 3}) | |
collection.insert({:x => 2}) | |
collection.insert({:x => 5}) |
This file contains hidden or 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
# This monkey patches tmm1's amqp gem to handle Basic Return | |
module AMQP | |
class ConsumerHijacker | |
attr_reader :header, :body | |
def receive(header, body) | |
@header, @body = header, body | |
end | |
This file contains hidden or 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
CHUNK_SIZE = 1024 * 1024 | |
EMPTY_STRING = ''.freeze | |
NEWLINE = "\n".freeze | |
# line_enum('path/to/huge/file').each do |line| | |
# puts line | |
# end | |
def line_enum(path) | |
Enumerator.new do |y| | |
File.open(path) do |io| |
This file contains hidden or 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
=ERROR REPORT==== 18-May-2011::14:20:55 === | |
** Generic server <0.15956.26> terminating | |
** Last message in was {'$gen_cast',emit_stats} | |
** When Server state == {ch,running,rabbit_framing_amqp_0_9_1,2,<0.15950.26>, | |
<0.15955.26>,<0.15950.26>,<0.15957.26>, | |
#Fun<rabbit_channel_sup.0.15412730>,none, | |
{set,0,16,16,8,80,48, | |
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[], | |
[]}, | |
{{[],[],[],[],[],[],[],[],[],[],[],[],[],[], |
OlderNewer