Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>RedBoy</title>
<meta name="description" content="ble test scanning">
<script src="jquery-1.11.1.min.js"></script>
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.phonegap.example"
versionCode = "10"
version = "1.0.0" >
<!-- versionCode is optional and Android only -->
<name>JRed</name>
app.get("/user/:userid", function (req, res, next) {
var id = parseInt(req.params.userid);
if (id === 'John') {
next();
} else {
//do something with the none John user id
}
});
meta = {
module : {
author : author,
title : title,
descrip : description,
clips : [{clip : {$ : {href : 'test'},
description : 'test'
}}]
}
}
@wonderdogone
wonderdogone / flattening.js
Last active August 29, 2015 14:28 — forked from joepie91/flattening.js
Promise flattening
doAsyncThing.then(function(result){
return doAnotherAsyncThing().then(function(result){
return doYetAnotherAsyncThing().then(function(result){
console.log("Done!");
});
});
}).catch(function(err){
/* This is where errors from *any* of the above promises end up. */
});
const cluster = require('cluster');
if (cluster.isMaster) {
let router = zmq.socket('router').bind('tcp://127.0.0.1:5433');
// forward messages between router and dealer
router.on('message', function() {
@wonderdogone
wonderdogone / new-promises-fallback.js
Created October 29, 2015 18:20 — forked from joepie91/new-promises-fallback.js
Fallback values in promise chains
/* UPDATED: This example has been changed to use the new object predicates, that were
* introduced in Bluebird 3.0. If you are using Bluebird 2.x, you will need to use the
* older example below, with the predicate function. */
var Promise = require("bluebird");
var fs = Promise.promisifyAll(require("fs"));
Promise.try(function(){
return fs.readFileAsync("./config.json").then(JSON.parse);
}).catch({code: "ENOENT"}, function(err){
async.series([
function(callback){
// do some stuff ...
callback(null, 'one');
},
function(callback){
// do some more stuff ...
callback(null, 'two');
}
],
class AutoComponent extends React.Component {
constructor() {
super()
var cls = this.constructor
var methods, methodName
while (cls !== AutoComponent) {
methods = Object.getOwnPropertyNames(cls.prototype)
for (var i in methods) {
methodName = methods[i]
if (methodName.match(/^on[A-Z]/) !== null) {
@wonderdogone
wonderdogone / Dockerfile
Created November 29, 2015 21:06 — forked from aaronjudd/Dockerfile
Meteor Dockerfile with imagemagick and phantomjs
############################################################
# Builds a Meteor 0.9.x+ application Docker image
#
# See: http://docs.docker.io/
#
# Important: Best to run from a clean directory that hasn't had meteor run in it.
# Important: packages/<pkg>/.npm and .build* should not exist
#
# Example usage:
# cd appdir #in app dir