Skip to content

Instantly share code, notes, and snippets.

View mgutz's full-sized avatar

Mario Gutierrez mgutz

View GitHub Profile
module.exports = function(gee) {
return {
scripts: {
src: "src/**/*.js",
pipe: function() { return [jshint(), concat(), uglify(), dest('dist/all.js')] }
}
};
};
// to watch? simple, add -w flag
@mgutz
mgutz / Projfile.coffee
Last active January 3, 2016 00:08
Projmate built on gulp filters syntax. Projmate can be run in imperative mode meaning it will run JavaScript or CoffeeScript files with the usual require and function goodness. It also runs project files in JSON in JSON, CSON or YAML format. The JSON mode is for the Projmate GUI. The JSON file can be edited by hand or the GUI and it is round-tri…
Promise = require("bluebird")
coffee = require("gulp-coffee")
dest = require("gulp").dest
less = require("gulp-less")
uglify = require("gulp-uglify")
exports.imports =
S: "./simple.coffee"
exports.project = (pm) ->
@mgutz
mgutz / gist:8343496
Last active January 2, 2016 18:29
The beauty of promises is they are values. Async and sync calls are handles the same within a `then` statement. In this example, async, sync and error handling are handled gracefully.
Promise = require('bluebird')
i = 0
printAsync = (cb) ->
setTimeout ->
console.log i++
cb()
, Math.floor((Math.random()*10)+1) # random 1..10
print = (action) ->
@mgutz
mgutz / pgadmin3_log_debug.md
Created December 21, 2013 16:51
DEBUG messages not logged in pgAdmin3 logs

Problem

There's a bug in pgAdmin3 query editor which sets client_min_messages to NOTICE regardless of the setting in the options dialog.

Workaround

Run this statement once in each query editor window using DEBUG logging

SET client_min_messages to 'DEBUG1';

@mgutz
mgutz / gist:3148405
Created July 20, 2012 03:02
go + postgres + pq library
package mine
import (
"fmt"
_ "github.com/bmizerany/pq"
"database/sql"
"testing"
)
@mgutz
mgutz / libluv.lua
Created February 4, 2012 18:17
require with index.lua
### index.lua
return require("./lib/luv")
### lib/luv.lua
local luv = {}
_G.task = function(name, description, ...)
end
return luv
@mgutz
mgutz / gist:802424
Created January 30, 2011 01:54
jquery-tmpl slow compared to string substitution
head.ready ->
# create 10,000 messages
s = ''
messages = []
for i in [0...10000]
messages.push from: 'me', text: "blah blah"
# using named functions
doSomething = (done) ->
mainWindow.menu "File", onFile
onFile = (er, file) ->
return cb(er) if er
file.openMenu onMenu
onMenu = (er, menu) ->
return er if er
var async = require('async');
var assert = require('assert');
engines = ['one', 'two', 'three'];
async.filter(engines, function(item, callBack){
callBack(item != 'two');
}, function(results){
assert.deepEqual(results, ['one', 'three']);
assert = require('assert')
class MyError
constructor: (@message, @name='bar') -> #nop
try
throw new Error('baz')
throw new MyError('foo')
catch err
console.log err.message