Skip to content

Instantly share code, notes, and snippets.

exports.sliceDomain = sliceDomain;
function sliceDomain (list, skip, limit) {
if (typeof skip === 'undefined') skip = 0;
if (limit < 0)
return list.slice(limit);
else
return list.slice(skip, skip + limit);
}
DICTIONARY = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("")
encode = (i) ->
return DICTIONARY[0] if i is 0
result = ""
base = DICTIONARY.length
while i > 0
result += DICTIONARY[(i % base)]
i = Math.floor(i / base)
result.split("").reverse().join ""
# Linear partition
# Partitions a sequence of non-negative integers into k ranges
# Based on Óscar López implementation in Python (http://stackoverflow.com/a/7942946)
# Also see http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK2/NODE45.HTM
# Dependencies: UnderscoreJS (http://www.underscorejs.org)
# Example: linear_partition([9,2,6,3,8,5,8,1,7,3,4], 3) => [[9,2,6,3],[8,5,8],[1,7,3,4]]
linear_partition = (seq, k) =>
n = seq.length
@ile
ile / gist:6237306
Created August 15, 2013 00:51
Images
test
@ile
ile / index.coffee
Created August 28, 2013 01:07
Racer bug?
app = require('derby').createApp(module)
.use(require 'derby-ui-boot')
.use(require '../../ui/index.coffee')
# ROUTES #
# Derby routes are rendered on the client and the server
app.get '/', (page) ->
page.render 'home'
<Body:>
<div class="jumbotron">
<h1>Hello world!</h1>
<p>Click the buttons in varying order and follow the console...</p>
<p><button class="btn" x-bind="click:assign1">set _page.user.section[1] = 'hello 1'</button></p>
<p><button class="btn" x-bind="click:assign2">set _page.user.section['abc'] = 'hello 2'</button></p>
</div>
@ile
ile / index.html
Created October 27, 2013 21:53
Racer bug #164, code to reproduce. https://github.com/codeparty/racer/issues/164
<import: src="./home">
<import: src="./list">
<import: src="./things">
<!--
Derby templates are similar to Handlebars, except that they are first
parsed as HTML, and there are a few extensions to make them work directly
with models. A single HTML template defines the HTML output, the event
handlers that update the model after user interaction, and the event handlers
that update the DOM when the model changes.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
# Whitelist collections
ALLOW_COLLECTIONS = {
'accounts': true
'users': true
}
module.exports = (shareClient) ->
# Hold on to session object for later use. The HTTP req object is only
# available in the connect event
shareClient.use 'connect', (shareRequest, next) ->
Trace: { [MongoError: E11000 duplicate key error index: myapp.auths.$local.email_1 dup key: { : "ilkkah@gmail.com" }]
name: 'MongoError',
connectionId: 1963,
err: 'E11000 duplicate key error index: myapp.auths.$local.email_1 dup key: { : "ilkkah@gmail.com" }',
code: 11000,
n: 0,
ok: 1 }
at /opt/derby/myapp/node_modules/share/lib/server/session.js:660:19
at /opt/derby/myapp/node_modules/share/lib/server/useragent.js:409:23
at /opt/derby/myapp/node_modules/livedb/lib/index.js:342:15