Skip to content

Instantly share code, notes, and snippets.

@szimek
szimek / aspect.js
Created July 21, 2011 13:44
devmeetings.pl aspect js task implementation
var aspect = {};
aspect.add = function (obj, fnName, aspectFn, when, once) {
if ('object' !== typeof obj) throw new TypeError('Must pass an object as the first argument');
obj = obj || window;
if (Array.isArray(fnName)) {
fnName.forEach(function (name) {
aspect._add(obj, name, aspectFn, when, once);
@szimek
szimek / backbone_extensions.js
Created June 15, 2011 10:20
Extensions for Backbone.
// TODO:
// - TemplateView
// - change the way templates are compiled (store compiled version inside view "class"?)
//
// - CollectionView
// - cleanup layout rendering if it depends on collection (remove collection container from DOM, rerender the layout and attach it again?)
// - store model views together with models (?)
//
// - ModelView
// - extend Model#toJSON to convert nested objects as well (http://rcos.rpi.edu/projects/concert/commit/got-requests-displaying-properly-again/)
@szimek
szimek / server.js
Created May 12, 2011 07:06
Basic static files server + reverse proxy for XMPP BOSH in NodeJS
var util = require('util'),
express = require('express'),
httpProxy = require('http-proxy');
var app = express.createServer(),
proxy = new httpProxy.HttpProxy();
app.configure(function() {
app.use(express.static(__dirname + "/public"));
});
@szimek
szimek / clearfix.css
Created May 8, 2011 09:27
Facebook CSS
.clearfix {
display: block;
zoom: 1;
}
.clearfix::after {
clear: both;
content: ".";
display: block;
font-size: 0;
@szimek
szimek / delayed_job_mailer.rb
Created March 23, 2011 09:01
Initial version - the idea is to make Mail::QueuedDelivery a proxy that takes original delivery_method as a parameter
# lib/mail/queued_delivery.rb
require 'mail'
module Delayed
class PerformableMail
attr_reader :mail
def initialize(mail)
@mail = mail
end
@szimek
szimek / init.el
Created March 5, 2011 21:01 — forked from mig/init.el
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
@szimek
szimek / executer.js
Created February 20, 2011 20:21
capybara-zombie server segmentation fault
var net = require('net'),
util = require('util'),
zombie = require('zombie'),
browser = new zombie.Browser,
buffer = "";
net.createServer(function (socket) {
socket.setEncoding('utf8');
socket.on('data', function (data) {
@szimek
szimek / webgl-constants-by-name
Created January 3, 2011 21:28
WebGL context constants
ACTIVE_ATTRIBUTES: 35721
ACTIVE_ATTRIBUTE_MAX_LENGTH: 35722
ACTIVE_TEXTURE: 34016
ACTIVE_UNIFORMS: 35718
ACTIVE_UNIFORM_MAX_LENGTH: 35719
ALIASED_LINE_WIDTH_RANGE: 33902
ALIASED_POINT_SIZE_RANGE: 33901
ALPHA: 6406
ALPHA_BITS: 3413
ALWAYS: 519
@szimek
szimek / config.ru
Created December 19, 2010 17:22
Script for serving static pages in a directory
# Using Ruby with "rack" gem - run using "rackup"
use Rack::Static, :urls => [""]; run nil
@szimek
szimek / dont_handle_asynchronously.rb
Created October 13, 2010 13:05
Disable delayed_job in tests
class ActiveRecord::Base
# Allow to bypass Delayed Job asynchronous handling
def self.dont_handle_asynchronously(*methods)
method_aliases = {}
methods.each do |method|
# TODO move this part into Delayed::MessageSending::ClassMethods#handle_asynchronously
aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
with_method, without_method = "#{aliased_method}_with_delay#{punctuation}", "#{aliased_method}_without_delay#{punctuation}"
method_aliases[method] = {:with => with_method, :without => without_method}