Skip to content

Instantly share code, notes, and snippets.

@szimek
szimek / Gemfile
Last active January 3, 2016 13:49
Find who's online in the local network
source "https://rubygems.org"
ruby "2.1.0"
gem "sinatra"
gem "sinatra-contrib"
gem "redis"

Date: [date]

Between us [company name] and you [customer name].

Summary:

In short; neither of us will share any confidential information about each-other, by any means, with anyone else.

What’s confidential information?

@szimek
szimek / caching-tips.md
Created August 2, 2012 15:34
HTTP/Rails caching/optimization tips
  1. Fragment caching
  1. Caching user's home page (same URL for all visitors, but different content)
  • can't cache response in gateway proxy
(function () {
if (window.webkitNotifications && typeof window.chat != 'undefined') {
Campfire.Responders.push('WebKitNotifier');
createNotifier();
createSettingsUI();
bindEvents();
function createNotifier() {
Campfire.WebKitNotifier = Class.create({
initialize: function(chat) {
# 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