Skip to content

Instantly share code, notes, and snippets.

@rlb3
rlb3 / bob.rb
Last active December 21, 2015 01:19
bob.rb
require 'ripper'
def Object.const_missing(name)
klass = const_set name, Class.new
klass.class_eval do
def method_missing name, *args
file, line_num, _ = caller[0].split(':')
file_contents = File.open(file).read

In Rails 3

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

(e.g. app/models/concerns/, app/models/products/)

@rlb3
rlb3 / github.css
Created September 15, 2013 19:29 — forked from theconektd/github.css
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@rlb3
rlb3 / simple_key_exchange.rb
Last active December 30, 2015 19:19
simple key exchange
#!/usr/bin/env ruby
shared_secret = SecureRandom.random_number 1_000_000_000
server1_secret = SecureRandom.random_number 10_000_000_000_000
server2_secret = SecureRandom.random_number 10_000_000_000_000
server1_public_key = shared_secret ^ server1_secret
server2_public_key = shared_secret ^ server2_secret
data = {
"books" => [
{
"title" => "Exceptional Ruby",
"revisions" => [
{"date" => "2011-12-01"},
{"date" => "2012-06-15"}
]
},
{
def compress(string)
compressed = string.chars.inject([]) do |accu, char|
if accu.empty? || accu.last.first != char
accu << [char, 1]
else
accu[0...-1] << [char, accu.last.last + 1]
end
end.map(&:join).join
[string, compressed].min_by(&:length)
@rlb3
rlb3 / build_openssl_dylib.sh
Last active August 29, 2015 14:10 — forked from bernardotorres/build_openssl_dylib.sh
Build latest OpenSSL Universal Binary on OSX.
#!/bin/bash
OPENSSL_VERSION="1.0.1g"
curl -O http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
@rlb3
rlb3 / org-tutorial.org
Created December 4, 2014 20:06
Orgmode Tutorial

Orgmode Tutorial

Todo list

  • State “DONE” from “TODO” [2012-02-15 Wed 08:05]
  • Title
  • Todo
  • Headers
  • Tags
@rlb3
rlb3 / weaving.org
Last active August 29, 2015 14:12 — forked from egh/weaving.org

Weaving a budget with org-mode & ledger

ledger comes with a built in budget system, but I wanted to get an “envelope”, or “YNAB” style budget working. While this was easy to do in theory, in practice it proved more difficult. The theory is pretty simple; enevelope budgeting merely requires you to create some new accounts to keep track of each “envelope” of money. But in practice, it requires a huge amount of duplicate data-entry, because even when using ledger’s automatic transactions, because each month’s budget is mostly the same but not necessarily exactly the same.The following

(setq gnus-select-method '(nnnil))
(setq gnus-secondary-select-methods '((nntp "news.gwene.org")))