This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Scaled-down Backbone.js demonstration | |
* By Jacob Oscarson (http://twitter.com/jacob414), 2010 | |
* MIT Licenced, see http://www.opensource.org/licenses/mit-license.php */ | |
$(function() { | |
window.ulog = function(msg) { $('#log').append($('<div>'+msg+'</div>')); } | |
// Faking a little bit of Backbone.sync functionallity | |
Backbone.sync = function(method, model, succeeded) { | |
ulog('<strong>'+method + ":</strong> " + model.get('label')); | |
if(typeof model.cid != 'undefined') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repr = (o, depth=0, max=2) -> | |
if depth > max | |
'<..>' | |
else | |
switch typeof o | |
when 'string' then "\"#{o.replace /"/g, '\\"'}\"" | |
when 'function' then 'function' | |
when 'object' | |
if o is null then 'null' | |
if _.isArray o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edit 1, thx @satyr! | |
groupby = (iter, keyfn) -> | |
grouped = {} | |
(grouped[keyfn e] ?= []).push e for e in iter | |
grouped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Really, really tiny message bus | |
# Yes, I know it leaks. | |
usig._bus = {} | |
usig.connect = (msg, cb) -> (usig._bus[msg] ?= []).push(cb) | |
usig.signal = (msg, args...) -> | |
cb args... for cb in usig._bus[msg] if usig._bus[msg] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Assumes Weinre running on localhost, and the file accessed via --> | |
<!-- another webserver also running on localhost. Accessing this file --> | |
<!-- locally (file://[..] protocol) doesn't provoke the issue. --> | |
<!-- Tried on OS X and Linux (recent Ubuntu) --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Weinre & Sencha Touch</title> | |
<script src="sencha-touch-1.0.1a.js"></script> | |
<script src="sencha-weinre.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Log as many events as possible, with event names grabbed from | |
// webkit sources: | |
// http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/dom/EventNames.h | |
known = [ | |
'abort', | |
'beforecopy', | |
'beforecut', | |
'beforeload', | |
'beforepaste', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just added a subprocess call to rsync to one of rb-fsevent's example | |
# scripts. Spookily easy. | |
require 'rubygems' | |
require 'rb-fsevent' | |
require 'open3' | |
include Open3 | |
fsevent = FSEvent.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseScreen extends Ext.Panel | |
title: 'Base panel' | |
iconCls: 'info' | |
class Screen1 extends BaseScreen | |
title: 'First screen' | |
html: 'Content of one screen' | |
class Screen2 extends BaseScreen | |
title: 'Second screen' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def subclass(Cls, name=None): | |
class _(Cls):pass | |
_.__name__ = name or 'subclass' | |
return _ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import py | |
def pytest_generate_tests(metafunc): | |
fargs = {} | |
if 'static' in metafunc.funcargnames: | |
fargs['static'] = 'stays the same' | |
if 'different' in metafunc.funcargnames: | |
for variant in (1,2): |
OlderNewer