This file contains 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
function MyController($scope, $firebaseCollection) { | |
// "images" - contains for example >10 000 children and we don't want to fetch them all at once | |
var imagesRef = new Firebase("https://<my-firebase>.firebaseio.com/images"); | |
// Creates an empty collection for images | |
// Collection should now track changes in imagesRef. | |
// Example methods: | |
// $push( snapshot ) - Push new children to collection | |
$scope.images = $firebaseCollection(imagesRef); |
This file contains 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
form(data-bind='submit: loadFoobar') | |
button(type='submit', data-bind='css: { loading: loadFoobar.loading }') |
This file contains 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
phoneBook = | |
[("betty","555-2938") | |
,("bonnie","452-2928") | |
,("patsy","493-2928") | |
,("lucille","205-2928") | |
,("wendy","939-8282") | |
,("penny","853-2492") | |
] | |
getNumberByName :: (Eq a) => a -> [(a, c)] -> Maybe c |
This file contains 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 System.Environment | |
import System.Directory | |
import System.IO | |
import Data.List | |
dispatch :: [(String, [String] -> IO ())] | |
dispatch = [ ("add", add) | |
, ("view", view) | |
, ("remove", remove) | |
, ("bump", bump) |
This file contains 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
function getData(callback) { | |
setTimeout(function() { | |
callback(null, Date.now()); | |
}, 1000); | |
} | |
function asyncCallback(generator) { | |
return function() { | |
var resolve = function(gen, data) { | |
var next = gen.next(data); |
This file contains 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
gulp.task "test", -> | |
server = require('./server/server.coffee').listen 9002 | |
new Promise (resolve, reject) -> | |
test = spawn 'casperjs', ['test', './test'], | |
stdio: 'inherit' | |
test.on 'close', (code) -> | |
server.close() | |
return reject(new Error("Tests failed")) unless code is 0 |
This file contains 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
#!/usr/bin/env node | |
var readline = require('readline'); | |
var actions = [], | |
actionCount = null; | |
var debug = function(data) { | |
require('fs').writeFileSync(Date.now() + '.log', data); | |
}; |
This file contains 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
user.populate 'creators', (err, user) -> | |
return next err if err? | |
async.map user.creators, (creator, done) -> | |
creator.populate 'city', done | |
, (err, creators) -> | |
return next err if err? | |
next response.ok creators |
This file contains 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
module.exports = ['$rootScope', 'Restangular', class FooService | |
constructor: (@$rootScope, @Restangular) -> | |
$rootScope.on '$foo', -> | |
# ... | |
getBars: -> | |
@Restangular.all('bars').getList() | |
module.exports = ['$rootScope', 'Restangular', ($rootScope, Restangular) -> | |
$rootScope.on '$foo', -> |
This file contains 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
path = require 'path' | |
express = require 'express' | |
bodyParser = require 'body-parser' | |
app = express() | |
if app.get('env') in ['development', 'test'] | |
app.use express.static path.join __dirname, '../', 'public' |
OlderNewer