Skip to content

Instantly share code, notes, and snippets.

View infra's full-sized avatar

Valentyn infra

View GitHub Profile
@infra
infra / Cakefile
Created December 10, 2012 19:37
Cakefile
#todo1: fs.readdirで取ったメンバがファイル/ディレクトリかチェックし、ディレクトリなら再帰
#todo2: errorをキャッチする
{exec} = require 'child_process'
{readdir} = require 'fs'
#
Sourcefile = []
#
task "coffee", "compile and minify #{Sourcefile}.coffee", (options) ->
readdir process.cwd(), (err,files)->
Sourcefile = files
@infra
infra / CakeFile
Created December 10, 2012 19:09 — forked from ecarter/CakeFile
Cakefile - with specified jade/coffee/stylus files
#
# Module Dependencies
#
{exec} = require 'child_process'
fs = require 'fs'
path = require 'path'
jade = require 'jade'
stylus = require 'stylus'
nib = require 'nib'
@infra
infra / app.js
Created December 3, 2012 21:36 — forked from twilson63/app.js
AngularJS Contact Form Example
function ContactCtrl($scope, $http) {
$scope.success = false;
$scope.httpError = false;
$scope.send = function() {
var job = { job: { klass: 'msg', args: [$scope.msg]}};
$http.post('/contact',job).
success(function(data){
$scope.success = true;
$scope.msg = {};
window.stoppingPropagation = (callback) -> (e) ->
e.stopPropagation()
callback(e)
angular.module('myApp',[]).directive 'ngTap', ->
(scope, element, attrs) ->
tapping = false
element.bind 'touchstart', stoppingPropagation (e) -> tapping = true
element.bind 'touchmove', stoppingPropagation (e) -> tapping = false
element.bind 'touchend', stoppingPropagation (e) -> scope.$apply(attrs['ngTap']) if tapping
@infra
infra / api.js
Created May 8, 2012 18:16 — forked from fwielstra/api.js
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@infra
infra / gist:2633193
Created May 8, 2012 07:00 — forked from steeleforge/gist:1035273
ExpressJS app.coffee
express = require('express')
app = module.exports = express.createServer()
app.configure ->
app.set 'views', __dirname + '/views'
app.set 'view engine', 'jade'
app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
@infra
infra / nodejs_express_mongodb.js
Created June 21, 2011 09:44 — forked from anonymous/nodejs_express_mongodb.js
trying to DRY up my code
// database.js
sys = require('sys');
var mongo = require('./lib/node-mongodb-native/lib/mongodb'),
Connection = mongo.Connection,
Server = mongo.Server,
BSON = mongo.BSONNative;
var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';
var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT'] : Connection.DEFAULT_PORT;