Skip to content

Instantly share code, notes, and snippets.

View optikalefx's full-sized avatar

Sean Clark optikalefx

View GitHub Profile
@optikalefx
optikalefx / gist:9180649
Last active August 29, 2015 13:56
express page never loads
app.get('/', function(req, res){
databaseCall().then((result) => {
"10".toFixed(2); // shit
res.send("hello");
});
});
@optikalefx
optikalefx / gist:9180821
Created February 24, 2014 02:15
Promise not erroring
var p = new Promise(function(resolve, reject) {
resolve("hi");
});
p.then(function(a) {
"10".toFixed(2);
console.log(a); // never happens
});
@optikalefx
optikalefx / gist:9286215
Created March 1, 2014 06:47
Node debug log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', '--production' ]
2 info using npm@1.3.11
3 info using node@v0.10.20
4 verbose node symlink /usr/bin/node
5 verbose readDependencies using package.json deps
6 verbose install where, deps [ '/var/ghost',
6 verbose install [ 'bcryptjs',
6 verbose install 'bookshelf',
6 verbose install 'busboy',
run(function * (resume) {
// connect to mongo
var db = yield MongoClient.connect(app.config.mongodb, resume);
// first we go through each pack and adjust for sounds & more
for (var j = 0; j < langs.length; j++) {
var lang = langs[i];
// get the collection for this language
var run = function(generatorFunction) {
var generatorItr = generatorFunction(function(one, two) {
if (arguments.length > 1 && one === null) {
return resume(two);
} else {
return resume(one);
}
});
function resume(callbackValue) {
app.util.unzipFile = function(url, destination, progress) {
var fileName = url.replace(/^.*[\\\/]/, '');
var withoutExt = fileName.split('.').shift();
var promise = new $.Deferred();
zip.unzip(url, destination,function(done) {
if( done === 0) {
// pass the success callback a file object of the new unzipped thing
resolveLocalFileSystemURL(destination + "/" + withoutExt, function(unzippedFileEntry) {
console.log("resolving zip promise");
@optikalefx
optikalefx / gist:3058310
Created July 6, 2012 05:53
render rows
// run 3 loops of 5, to fill with loading boxes
for(var i=0;i<3;i++) {
for(var j=0;j<5;j++) {
$(".news-row:eq("+i+") .news-inner-row").append(
render(template)({
title : "",
image : "",
author : "",
source : "loading...",
body : []
@optikalefx
optikalefx / gist:3058311
Created July 6, 2012 05:53
render rows
// run 3 loops of 5, to fill with loading boxes
for(var i=0;i<3;i++) {
for(var j=0;j<5;j++) {
$(".news-row:eq("+i+") .news-inner-row").append(
render(template)({
title : "",
image : "",
author : "",
source : "loading...",
body : []
// run 3 loops of 5, to fill with loading boxes
for(var i=0;i<3;i++) {
for(var j=0;j<5;j++) {
$(".news-row:eq("+i+") .news-inner-row").append(
render(template)({
title : "",
image : "",
author : "",
source : "loading...",
body : []
$.post("npr/get/41",function(res) {
// loop and place
for(i=0;i<res.length;i++) {
// remove one of the loading boxes
$(".news-row:eq(2) .news-inner-row .loading:first").remove();
// add a good article
$(".news-row:eq(2) .news-inner-row").append(
render(template)(res[i])
);
}