Skip to content

Instantly share code, notes, and snippets.

@szimek
szimek / a.md
Created June 29, 2012 11:03 — forked from rkh/a.md

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Netflix
  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
(function () {
if (window.webkitNotifications && typeof window.chat != 'undefined') {
Campfire.Responders.push('WebKitNotifier');
createNotifier();
createSettingsUI();
bindEvents();
function createNotifier() {
Campfire.WebKitNotifier = Class.create({
initialize: function(chat) {
@szimek
szimek / presentation.md
Created January 24, 2012 09:51
HTTP caching in Rails

HTTP caching

Kinds of caches

  • Browser
  • Proxy
  • Gateway

TODO Difference between proxy and gateway caches.

# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'

Model based constraints:

constraints Account do
  resources :users
end

class Account < AR::Base
  def self.matches(request)
    Account.find_by_subdomain(request.subdomain).present?
  end
@szimek
szimek / basecamp-daily-report.user.js
Created December 7, 2011 14:22
Adds a button on time entries page to create a daily report for a user.
// ==UserScript==
// @match https://objectreload.basecamphq.com/projects/*
// ==/UserScript==
var container = document.getElementById('report_link_block'),
link = document.createElement('a'),
content = document.createTextNode('Create a daily report'),
date = new Date(),
user,
path;
@szimek
szimek / gameoflife.lisp
Created December 5, 2011 19:56 — forked from qoobaa/gameoflife.lisp
Game of live in LISP
(defun next-generation (board)
(loop for row being the elements of board using (index x) collect
(loop for col being the elements of row using (index y) collect
(next-cell-p x y board))))
(defun next-cell-p (x y board)
(let ((count (neighbours-count x y board))
(cell (cell-p x y board)))
(or
(and cell (or (= count 2) (= count 3)))
@szimek
szimek / engines.md
Created November 13, 2011 13:24
Steps for creating Rails engine to separate existing app into smaller ones
  1. Isolated engine - short description
  2. Create an engine: rails plugin new <name> --full --mounted - undocumented
  3. mv <name> vendor/apps
  4. cleanup engine's Gemfile (?)
  5. add engine to main app's Gemfile
  6. routes in engine's config/routes.rb then mount in main app's config/routes.rb
  7. views - lookup paths; default paths, might need to reverse order
  8. tests - dummy app; use the main app instead
  9. namespaced controllers and views
MyApp::Application.configure do
silence_warnings do
begin
require 'pry'
IRB = Pry
rescue LoadError
end
end
end
root :to => "users#dashboard", :constraints => lambda { |r| r.env["warden"].authenticate? }
root :to => "home#index"