Skip to content

Instantly share code, notes, and snippets.

# c = CSVBuilder.new ['column 1 name', 'column 2 name', 'column 3 name']
# rowdata.each do |r|
# special_column = r.boolean ? 'YES' : 'NO'
# c.add_row [special_column, r.name, r.date]
# end
# c.export('optional_filename.csv')
class CSVBuilder
def initialize(head)
if head.is_a?(Array)
@veloper
veloper / 0-readme.md
Created September 27, 2012 13:29 — forked from burke/0-readme.md
ruby-1.9.3-p194 cumulative performance patch.

Patched ruby 1.9.3-p194 for 30% faster rails boot

Overview

This script installs a patched version of ruby 1.9.3-p194 with boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Many thanks to funny-falcon for the performance patches.

@veloper
veloper / gist:4155031
Created November 27, 2012 15:57 — forked from ss-kelsmj/gist:4154851
Which is more readable
def sum_data(index, page, data)
t = []
page.each do |p|
if t.length == 0
t = get_data_array(p, index, data)
else
temp = get_data_array(p, index, data)
t.each_index do | i |
t[i] += temp[i]
end
@veloper
veloper / .irbrc
Created October 22, 2013 20:49 — forked from unixmonkey/.irbrc
require 'pp'
require 'irb/completion'
require 'rubygems'
require 'wirble'
require 'hirb'
Wirble.init
Wirble.colorize
IRB.conf[:AUTO_INDENT]=true
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@veloper
veloper / protobuf-serialization.md
Created May 22, 2023 14:00 — forked from kchristidis/protobuf-serialization.md
Notes on protocol buffers and deterministic serialization (or lack thereof)

There doesn't seem to be a good resource online describing the issues with protocol buffers and deterministic serialization (or lack thereof). This is a collection of links on the subject.

Protocol Buffers v3.0.0. release notes:

The deterministic serialization is, however, NOT canonical across languages; it is also unstable across different builds with schema changes due to unknown fields.

Maps documentation:

Wire format ordering and map iteration ordering of map values is undefined, so you cannot rely on your map items being in a particular order.