Skip to content

Instantly share code, notes, and snippets.

View solnic's full-sized avatar

Peter Solnica solnic

View GitHub Profile
@mbj
mbj / book.rb
Created December 19, 2012 19:53
RFC: Uncovered mutation example for blog post by @solnic
class Book
attr_reader :sections
def initialize
@sections = []
@index = {}
end
def section(number)
@index.fetch(number) do
@solnic
solnic / dm1.txt
Created December 4, 2012 12:57
dm1 vs dm2 - eager loading association
1.9.3p327 :011 > Benchmark.bm { |x| x.report { User.all.each { |u| u.city } } }
user system total real
4.320000 0.010000 4.330000 ( 4.344362)
@dkubb
dkubb / git-remove-merged.sh
Last active March 8, 2023 17:24 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
git remote update &&
git remote prune origin &&
git branch -r --merged origin/master |
awk -F"/" '!/(>|master)/ {print $2}' |
xargs -rL1 git push origin --delete
@paulmillr
paulmillr / active.md
Last active March 17, 2025 08:21
Most active GitHub users (by contributions). https://paulmillr.com

Most active GitHub users (git.io/top)

The list would not be updated for now. Don't write comments.

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Because of GitHub search limitations, only 1000 first users according to amount of followers are included. If you are not in the list you don't have enough followers. See raw data and source code. Algorithm in pseudocode:

githubUsers
@bokmann
bokmann / ActiveRepository.rb
Created March 27, 2012 16:15
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@chetan
chetan / yardoc_cheatsheet.md
Last active April 3, 2025 18:35
YARD cheatsheet
@ku1ik
ku1ik / gist:1694742
Created January 28, 2012 15:44
Install Cyanogenmod7 on HTC Desire S with hboot 2.00.0002

There's no need to make the phone S-OFF (like some people say).

  • Disable fast/quick reboot (Settings » Power » Fastboot)

  • Download fastboot binary

  • Unlock bootloader: http://htcdev.com/bootloader/

    Put the phone in Fastboot USB mode (Turn off, hold Volume Down + Power)

@ahoward
ahoward / proc-gt-module.rb
Created November 29, 2011 22:28
proc > module
#! /usr/bin/env ruby
# ClassMethods/InstanceMethods as modules are nice. but procs are mo betta. you can't do any of the following via modules.
#
module M
ClassMethods = proc do
class << self
alias_method 'bar', 'foo'
end

Since Obie Fernandez posted his demands as a consultant I thought I would post mine too.

  • I will be paid $10,000 per day, in $50 bills, in a titanium briefcase that you will purchase for the sole purpose of providing a container for my money. You may not re-use the briefcase for the next day's payment.
  • The $50 bills must have been printed in the last three months and handled by no more than 2 people.
  • Anybody handling the money must do so with clean white gloves that must be placed on the hand immediately before touching the briefcase. If the hand leaves the briefcase, the white gloves must be replaced with new ones before the briefcase is touched again.
  • I will arrive in your city by a private jet. Fuel and any other costs incurred by this trip will be paid by you, and is not included in the $10k/day fee.
  • Transportation from my jet to your workplace must be performed by a driver who is between the ages of 50
@dkubb
dkubb / gist:1294429
Created October 18, 2011 01:57
Reflect on a PostgreSQL Database
# gem install backports veritas veritas-optimizer veritas-do-adapter do_postgres
require 'pp'
require 'rational'
require 'rubygems'
require 'backports'
require 'backports/basic_object'
require 'veritas'
require 'veritas-optimizer'