Skip to content

Instantly share code, notes, and snippets.

@drewwells
drewwells / mtime_file_watcher.py
Created September 30, 2015 06:34
do not watch the entire gopath
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@christopherhesse
christopherhesse / gist:fee14d722b60121725dc
Last active August 29, 2015 14:25
appengine image API with GCS
import (
"appengine/blobstore"
aeimage "appengine/image"
)
func servingURL(c appengine.Context) error {
blobKey, err := blobstore.BlobKeyForFile(c, "/gs/bucketname/file")
if err != nil {
return err
}
@bobylito
bobylito / import.js
Created March 22, 2015 11:18
Import data to Algolia with Node.js streams.
// npm install agentkeepalive batch-stream csv-parse stream-transform
var HttpsAgent = require('agentkeepalive').HttpsAgent;
var Algolia = require('algolia-search');
var stream = require( 'stream' );
var parse = require('csv-parse');
var fs = require('fs')
var transform = require('stream-transform');
var Batch = require( 'batch-stream' );
@rattrayalex
rattrayalex / app.coffee
Last active September 11, 2018 23:46
Demo
Bacon = require('baconjs')
Imm = require('immutable')
React = require('react')
window.Actions =
changeFirstName: new Bacon.Bus()
changeLastName: new Bacon.Bus()
changeCountry: new Bacon.Bus()
addCountryBird: new Bacon.Bus()
addFriend: new Bacon.Bus()
@zeekay
zeekay / mtime_file_watcher.py
Last active January 8, 2022 20:59
Replacement MtimeFileWatcher for App Engine SDK's dev_appserver.py
#!/usr/bin/env python
#
# Replacement `MtimeFileWatcher` for App Engine SDK's dev_appserver.py,
# designed for OS X. Improves upon existing file watcher (under OS X) in
# numerous ways:
#
# - Uses FSEvents API to watch for changes instead of polling. This saves a
# dramatic amount of CPU, especially in projects with several modules.
# - Tries to be smarter about which modules reload when files change, only
# modified module should reload.
@nateps
nateps / gist:02d0b0293880905476bd
Created July 12, 2014 00:45
Example ShareJS access control middleware for use with Derby
# 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) ->
@pinscript
pinscript / home.html
Last active September 23, 2017 01:18
{{define "body"}}
This is the start page.
<br><br>
Check out <a href="/user/5">user 5</a> or <a href="/user/7">user 7</a>.
{{end}}
@vmakhaev
vmakhaev / access.js
Created December 23, 2013 03:26
Idea of new racer-access api
var racerAccess = require('racer-access');
derby.use(racerAccess);
var store = derby.createStore();
// This is current racer-access api
store.allow('change', 'users', function(docName, changeTo, snapshotData, connectSession) {
return;
});
ALLOWED_COLLECTIONS = [
'auths' # Private user data
]
store.allow 'create', 'auths', (docId, newDoc, session) ->
console.log '[Auths] CREATE'
undefined
store.allow 'all', 'auths.*', (docId, relPath, opData, docBeingUpdated, session) ->
console.log '[Auths] CHANGE'
@enjalot
enjalot / hook.coffee
Last active December 20, 2015 05:58
derby server side hooks (to hold you over for now)
#make a hook
store.hook 'change', 'collection.*.foo', (docId, value, op, session, backend) ->
model = store.createModel()
#logic
#setup the hook method
store.hook = (method, pattern, fn) ->
store.shareClient.use 'after submit', (shareRequest, next) ->
{opData} = shareRequest