Skip to content

Instantly share code, notes, and snippets.

View seanmonstar's full-sized avatar

Sean McArthur seanmonstar

View GitHub Profile
var Class = require('../../lib/class'),
model = require('../../lib/model'),
AjaxSync = require('../../lib/sync/Ajax');
var Task = module.exports = new Class({
Extends: model.Model,
fields: {
id: model.fields.NumberField(),
@seanmonstar
seanmonstar / compiled.js
Created August 4, 2011 18:15
Template file, and compiled into a function
View.$cache["tasks"]= function(obj){
var p=[],
print=function(){
p.push.apply(p,arguments)
};
with(obj){
p.push('<form action="" method="post"><label><input type="text" name="title" placeholder="Task title..." /></label><button type="submit">Add Task</button></form><ul id="TasksList">');
tasks.each(function(t){
p.push('<li class="task ', t.identity(), '"><span class="title">', t.get("title"), '</span><a href="#" class="delete">Delete</a></li>')
});
@seanmonstar
seanmonstar / json.js
Created August 9, 2011 01:24
Options for an ES field count filter
{
"filter": {
"script": {
"script": "doc['copies'].values.size() >= 1'"
}
},
"fields": ["id"]
}
@seanmonstar
seanmonstar / catch.coffee
Created September 6, 2011 02:21
Coffee exceptions
req = (request, errorOnTimeout) ->
try
request.send
catch InvalidHeaderError, e
console.error 'wrong headers'
catch TimeoutError, e
if errorOnTimeout
console.error 'timed out!'
else
console.log 'timed out, trying once more'
@seanmonstar
seanmonstar / dont-self-or-that.js
Created October 29, 2011 00:03
If you use `var self = this`, die.
var Example = new Class({
initialize: function() {
// i now hate you if you do this in my codez
var self = this; // or that.
// 10 or 20 lines down, in another closure, I have to read up to
// make sure `self` is set the `this` that I want
// instead, this is they way to go
var example = this;
@seanmonstar
seanmonstar / closure-gotcha.py
Created December 9, 2011 22:06
A gotcha in Python's closures
def something_awesome():
awesome = 1
def increase_awesomeness():
awesome += 1
increase_awesomeness()
return awesome
function module(window) {
console.log('normal window', window);
console.log('a closure', (function() { return this; })());
console.log('new Func', (new Function('', 'return window'))());
}
module(); //this makes window undefined...sorta...
@seanmonstar
seanmonstar / gist:5286698
Last active December 15, 2015 16:09
Proposal for Tent-RSS bi-directional bridge.

Tent <-> RSS Bridge

Needs a name (smoke-signals?)

This is an open source, hosted, bi-directional bridge of Tent and RSS. It would be hosted somewhere, and installed as an app against your tent server.

Using Python, because it doesn't make us claw our eyes out. Likely with the Flask framework.

Register as an app

@seanmonstar
seanmonstar / gist:5288105
Created April 1, 2013 21:58
Hashtags as Tag Mentions in Tent v0.3

Hashtags as Tag Mentions

Take this example post with hashtags:

Tent v0.3 is going to totally change the game when all is said and done! #tentdev

What if my client parsed this content before creating the post, and pulled out the hashtag, using this process:

  • Find #hashtags
  • For each hashtag, check to see if a tag (ex: tentdev) post exists, creating if it doesn't.
@seanmonstar
seanmonstar / experimental.js
Last active December 17, 2015 05:49
navigator.id.experimental.login()
/*global setTimeout:true, navigator:true*/
/*
* navigator.id.experimental.login(options)
* - takes same options as navigator.id.request()
* - returns a Promise
* : navigator.id.experimental.login({ siteName: 'Foo"})
* .then(verifyAssertion, onCancel);
*
* navigator.id.experimental.automatic([function])
* - takes an optional callback function