Skip to content

Instantly share code, notes, and snippets.

@oszbart
oszbart / FT2014_slides
Last active August 29, 2015 14:01
Front-Trends 2014 slides
Day 1
Julian Cheal
Dancing with Robots
?
Tero Parviainen
Build Your Own AngularJS
?
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
Devise::ALL.dup.each do |name|
class_name = name.to_s.classify
to_class = WebsiteAccount
to_instance = :website_account
class_eval <<-METHODS, __FILE__, __LINE__ + 1
module Devise::Models::Delegated#{class_name}
extend ActiveSupport::Concern
included do
@pairing
pairing / active_model_lint.rb
Created October 21, 2010 19:03
RSpec ActiveModel Lint shared example
# adapted from rspec-rails http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb
shared_examples_for "ActiveModel" do
require 'test/unit/assertions'
require 'active_model/lint'
include Test::Unit::Assertions
include ActiveModel::Lint::Tests
# to_s is to support ruby-1.9
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
#! /usr/bin/env ruby
status = DATA.flock(File::LOCK_EX | File::LOCK_NB)
if status == 0
puts "we have the lock..."
sleep
else
@cowboy
cowboy / multi-firefox-fixer.sh
Created March 14, 2011 02:17
Multi-Firefox Fixer: Run multiple versions of Firefox simultaneously! (note: doesn't work on Windows)
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF
Multi-Firefox Fixer - v0.2 - 4/26/2011
http://benalman.com/
Usage: `basename "$0"`
Run this shell script from beside (in the same parent directory as) one or more
Firefox*.app or Aurora*.app applications and it will "fix" those Firefoxes to
module Test
module Unit
TestCase = RSpec::Core::ExampleGroup
end
end
class Test::Unit::TestCase
def self.inherited(host)
host.set_it_up host.name.gsub(/(Spec|Test)/,'')
def host.method_added(name)
@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/)
@creationix
creationix / EventLoop.js
Created June 21, 2011 05:56
Userspace EventLoop for JavaScript
// Make a user-space event loop for doing smart event propigation with zero*
// race conditions.
//
// *(If you are unable to get at the event-source, an automatic setTimeout will
// be created, and there is a small chance some other native event may get in
// before it.)
function makeLoop() {
// Private //
@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);