Skip to content

Instantly share code, notes, and snippets.

Avatar

Orlin M Bozhinov orlin

  • Astrolet
  • Varna, Bulgaria
  • Twitter @orlin
View GitHub Profile
@jimeh
jimeh / jquery.myplugin.coffee
Created Apr 7, 2011
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
View jquery.myplugin.coffee
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
@DavidYKay
DavidYKay / gist:912765
Created Apr 10, 2011
"Can Code Be Like Literature" - Jeremy Ashkenas
View gist:912765
Jeremy
Absolutely brilliant
both technically
and oratorically
He wrote CoffeeScript
1st place 5k
21 min, 3 seconds
<7min mile
Big picture
@topfunky
topfunky / Cakefile
Created Apr 14, 2011
Watch both Sass and Coffee files and compile on change (for Node.js)
View Cakefile
###
Modified from https://github.com/jashkenas/coffee-script/blob/master/Cakefile
Part of an upcoming PeepCode screencast. This snippet is MIT Licensed.
###
{spawn, exec} = require 'child_process'
task 'assets:watch', 'Watch source files and build JS & CSS', (options) ->
runCommand = (name, args) ->
@jboesch
jboesch / AjaxForm Jasmine Test.js
Created Apr 20, 2011
RequireJS, BackboneJS and testing with Jasmine. Whew.
View AjaxForm Jasmine Test.js
describe("AjaxForm", function() {
// Local vars for manipulation
var $form = null,
_requirejs_loaded = false,
found_errors = false,
submitted_successfully = false,
AjaxFormInstance = null,
RequireJSViews = {
AjaxFormView: null
View underpants.coffee
# Extend jQuery objects with Underscore collection methods.
#
# Each collection method comes in two flavors: one prefixed
# with _, which yields a bare DOM element, and one prefixed
# with $, which yields a jQuery-wrapped element.
#
# So if `this` is a jQuery object, instead of:
#
# _.max @, (el) -> $(el).height()
#
View gist:950965
# Conditional decrement.
#
# Decrement the value of a key only if the current value is greater than
# a specified value.
require 'rubygems'
require 'redis'
r = Redis.new
cond_decr = <<LUA
@bernerdschaefer
bernerdschaefer / gist:962715
Created May 9, 2011
some bash helpers for working with padrino projects
View gist:962715
alias rake="time rake"
# Run `padrino rake` when inside a padrino project,
# otherwise run the normal rake command.
function rake () {
if [[ -f ".components" ]]; then
padrino rake $*
else
ruby -S rake $*
fi
@igrigorik
igrigorik / TweetEvent.java
Created May 27, 2011
wrapping esper with JRuby embrace
View TweetEvent.java
// A simple Tweet POJO:
// $> javac TweetEvent.java
public class TweetEvent {
private String user;
private String text;
private String timezone;
private int retweets;
public TweetEvent(String user, String text, String timezone, int retweets) {
@jicksta
jicksta / gist:1001736
Created Jun 1, 2011
Jasmine shared behavior for asserting that a certain event on an element exposed as a Backbone view property properly executes the expected view instance method
View gist:1001736
function assertViewAction(viewClass, eventCallbackName, elementAccessorName, eventName, viewReference) {
it("should run the " + eventCallbackName + " action when the " + elementAccessorName + " gets a " + eventName + " event (assertViewAction)", function() {
var isPrototypal = eventCallbackName in viewClass.prototype;
if (isPrototypal) {
spyOn(viewClass.prototype, eventCallbackName);
}
var view = viewReference();
if (!isPrototypal) {
spyOn(view, eventCallbackName);
}
@kriszyp
kriszyp / my-widget.js
Created Jun 24, 2011
This is how I want to write structured documentation and unit tests
View my-widget.js
/* This is the module, the implementation, distinct from the specification/interface. */
define([...deps...], function(){
return function(options){
...
};
});