Some CoffeeScript (verbosely commented for clarity)
# Override Rails handling of confirmation
$.rails.allowAction = (element) ->
# The message is something like "Are you sure?"
message = element.data('confirm')
/* Ismael Celis 2010 | |
Simplified WebSocket events dispatcher (no channels, no users) | |
var socket = new FancyWebSocket(); | |
// bind to server events | |
socket.bind('some_event', function(data){ | |
alert(data.name + ' says: ' + data.message) | |
}); |
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations) | |
# By Peter Cooper | |
# | |
# MIT license | |
# | |
# * Not advised to use in your production environment! ;-) | |
# * Requires Ruby 1.9 | |
# * Supports A and CNAME records | |
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance | |
# * All records get the same TTL |
module ActiveRecord::NestedAttributes | |
module ClassMethods | |
def accepts_nested_attributes_for(*attr_names) | |
options = { :allow_destroy => false, :update_only => false } | |
options.update(attr_names.extract_options!) | |
# Modified stuff | |
#options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only) | |
options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only, :allow_existing) |
# This is an incomplete implementation. | |
module MongoMapper | |
module NestedAttributes | |
def self.included(base) | |
base.extend(ClassMethods) | |
base.send :include, InstanceMethods | |
end | |
module ClassMethods | |
def accepts_nested_attributes_for(*attr_names) |
/* Abstract event binding | |
Example: | |
var MyEventEmitter = function(){}; | |
MyEventEmitter.prototype = new AbstractEventsDispatcher; | |
var emitter = new MyEventEmitter(); | |
// Bind to single event | |
emitter.bind('foo_event', function(data){ alert(data)} ); |
/* | |
MAKE the whole block actionable with CSS only. | |
<div id="block" title="read more about ..."> | |
<h3><a href="...">Some title here</a></h3> | |
<p>bla bla bla .... bla!</p> | |
</div> | |
*/ |
(function(global) { | |
var silpUrl = '//s3-eu-west-1.amazonaws.com/silp.shootitlive.com/js/silp.min.js'; | |
// Globals | |
if(!global.Silp) { global.Silp = {}; }; | |
var Silp = global.Silp; | |
// To keep track of which embeds we have already processed | |
if(!Silp.foundEls) Silp.foundEls = []; |
# coding=UTF-8 | |
from __future__ import division | |
import nltk | |
from collections import Counter | |
# This is a simple tool for adding automatic hashtags into an article title | |
# Created by Shlomi Babluki | |
# Sep, 2013 | |