A Pen by Le Roux Bodenstein on CodePen.
This file contains hidden or 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 = reqr = (path, m) -> | |
| before = new Date() | |
| if m | |
| ret = m.require path | |
| else | |
| ret = require path | |
| ms = new Date - before | |
| if m | |
| relative = m.filename.replace __dirname, '' | |
| p = "#{path} from .#{relative}" |
This file contains hidden or 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
| * update README.md to mention "make deploy" and not "make upload" | |
| * update README.md to link to wiki page | |
| * update Makefile to include `pwd` in -path (see below) | |
| * update README.md with build instructions for OSX: | |
| (I'm probably missing some things because I've built some things before, but | |
| those are all probably fairly standard "build toolchain" packages.) |
This file contains hidden or 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
| slugify = (title) -> | |
| title | |
| .toLowerCase() | |
| .replace(/\ /g, '-') # spaces to dashes | |
| .replace(/[^\w-]+/g, '') # remove anything that's not ascii A-Za-z0-9 | |
| .replace(/[-]+/g, '-') # remove consecutive dashes |
This file contains hidden or 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
| # This could be used as a client-side polyfill for node.js's url.parse() | |
| parseURL = (url, parseQuery) -> | |
| # http://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript | |
| parser = document.createElement('a') | |
| parser.href = url | |
| parsed = | |
| protocol: parser.protocol | |
| host: parser.host | |
| hostname: parser.hostname |
This file contains hidden or 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
| # http://www.w3.org/TR/AERT#color-contrast | |
| getBrightness = (rgb) -> | |
| sum = parseInt(rgb[0])*299 + parseInt(rgb[1])*587 + parseInt(rgb[2])*114 | |
| brightness = Math.round(sum / 1000) # 0 (dark) to 255 (light) | |
| colorDifference = (a, b) -> | |
| max = Math.max | |
| min = Math.min | |
| d0 = max(a[0], b[0]) - min(a[0], b[0]) |
This file contains hidden or 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
| #!/bin/bash | |
| while : | |
| do | |
| echo "Press [CTRL+C] to stop.." | |
| curl -i -F image=@trollface.png http://127.0.0.1:3000/ | |
| done |
This file contains hidden or 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
| pg = require 'pg' | |
| executeSQL = module.exports.executeSQL = (sql, params, callback) -> | |
| # for executing sql outside of transactions | |
| throw new Error "DATABASE_URL not set" unless process.env.DATABASE_URL | |
| pg.connect process.env.DATABASE_URL, (err, client, done) -> | |
| return callback(err) if err | |
| client.query sql, params, (err, result) -> | |
| done(client) # gets called regardless | |
| return callback err, result |
This file contains hidden or 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
| # extract the weight and style from a google font variant string | |
| splitVariant = (variant) -> | |
| weight = 'normal' | |
| style = 'normal' | |
| unless variant == 'regular' | |
| if variant == 'italic' | |
| style = 'italic' | |
| else | |
| weight = variant[..2] | |
| italic = variant[3..] |
This file contains hidden or 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
| info: Creating snapshot 0.0.1-5 | |
| info Uploading: [ ] 0% | |
| info: Updating app nko3-nodesque | |
| info: Activating snapshot 0.0.1-5 for nko3-nodesque | |
| info: Starting app nko3-nodesque | |
| error: Error running command deploy | |
| error: Nodejitsu Error (500): Internal Server Error | |
| error: There was an error while attempting to deploy the app | |
| error: | |
| error: Rackspace Error (404): Item not found |