Skip to content

Instantly share code, notes, and snippets.

@jmaicher
jmaicher / gist:1657799
Created January 22, 2012 17:41
Usage of the jasmine-require helpers (https://github.com/scottburch/jasmine-require)
describe("Module1", function(){
var Module1;
requireDependencies(['module1/module1'], function(_Module1) {
Module1 = _Module1;
});
it("should be defined", function(){
expect(Module1).toBeDefined();
//= require require
require.config({
'baseUrl': '/assets'
});
@jmaicher
jmaicher / example-1.js
Created January 12, 2012 17:17
How Backbone.js Implements Inheritance
// create a constructor which inherits from Backbone.Model
var ToDo = Backbone.Model.extend(
// instance properties
{
toJSON: function() { ... }
},
// static properties
{
createFromJSON: function(jsonObj) { ... }
}
input, textarea, select {
font: 13px Courier New,Helvetica,Verdana,Arial,Sans-Serif;
}
/* because courier new in bold is ugly */
#commentform #submit {
font-weight: normal;
}
@jmaicher
jmaicher / gist:1321972
Created October 28, 2011 09:38
Speed improvements running cucumber against spork (rails 3.1)
# running cucumber without spork
$ time cucumber
Using the default profile...
0 scenarios
0 steps
0m0.000s
cucumber 5.09s user 0.86s system 99% cpu 5.971 total
# running cucumber against spork
@jmaicher
jmaicher / gist:1050834
Created June 28, 2011 09:59
Code from hell
<?php
function rechter_rand_unten($rechter_rand)
{
global $rechter_rand;
if ($rechter_rand == 1)
{ ?></td>
<td width="140" class="loop_navi_rechts">
<table width="140" cellspacing="0" cellpadding="0">
<tr>
<td>
@jmaicher
jmaicher / gist:1018585
Created June 10, 2011 10:17
WARNING: Global access to Rake DSL methods is deprecated
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method [..]::Application#task called at [..]/gems/railties-3.0.5/lib/rails/application.rb:214:in `initialize_tasks'
@jmaicher
jmaicher / gist:1016933
Created June 9, 2011 15:13
Playing with streama
class Activity
include Mongoid::Document
include Streama::Activity
activity :follow_user do
actor :user, :cache => [:name]
target :user, :cache => [:name]
end
activity :follow_event do
@jmaicher
jmaicher / gist:838833
Created February 22, 2011 15:28
Querying embedded documents from embedded document
# ################
# Models
# ################
class Event
include Mongoid::Document
embeds_many :organizers, :class_name => "EventOrganizer"
end
module UrlHelper
def generate_my_url(obj)
my_path({ :obj_id => obj.slug })
end
# [..]
end