Skip to content

Instantly share code, notes, and snippets.

@veloper
veloper / JSONVue-Dark.css
Created March 15, 2024 16:08
Dark Mode view for JSONVue Chrome Extension that is readable
body {
white-space: pre;
font-family: monospace;
color: #ddd; /* Light grey color for general text */
background-color: black; /* Black background */
}
a {
color: #66ccff; /* Light blue color for links */
text-decoration: none; /* Removes the underline */
@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.

#compdef thor
#autoload
TIME=`expr $(date +%s) / 60`
TMP_FILE=`echo "/tmp/thor_cached_comps.$TIME.txt"`
if [ -e $TMP_FILE ]; then
# do nothing
else
class NormalizeNetworkSupplierWebsites < ActiveRecord::Migration
class NetworkSuppliersTable < ActiveRecord::Base
self.table_name = "network_suppliers"
end
def up
NetworkSuppliersTable.where("website IS NOT NULL").find_each do |record|
record.website = record.website.to_s.split.grep(UrlValidator::REGULAR_EXPRESSION).first # The first valid website or nil
record.save! if record.changed?
brew uninstall wkhtmltopdf && brew install https://raw.github.com/mxcl/homebrew/6e2d550cf4961129a790bfb0973f8e88704f439d/Library/Formula/wkhtmltopdf.rb
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 / .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
@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 / 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.

# 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)