Skip to content

Instantly share code, notes, and snippets.

var firmata = require( "firmata" );
var board = new firmata.Board( "COM6", function() {
console.log( "Connected" );
console.log( arguments );
});
board.sp.on('data', function(data) {
console.log( data );
});
c:\src>node child-test.js
[STR] stdout "stdout"
[STR] stderr "stderr"
[END] code 123
[END] stdout "stdout"
[END] stderr "stderr"
c:\src>node child-test.js
[STR] stdout "stdout"
[STR] stderr "stderr"
function flushExit( process, exitCode ) {
if ( process.stdout._pendingWriteReqs ) {
setTimeout(function() {
flushExit( process, exitCode );
}, 1 );
}
else {
process.exit( exitCode );
}
}
// Lots of indentation variety on this file trying
// to get JSHint to throw an indentation error
module.exports = function( grunt ) {
grunt.initConfig({
jshint: {
all: [
"Gruntfile.js"
],
options: {
indent: 1
// JSHint chokes when a UTF8 file is read that includes the BOM.
// This bug is fixed in grunt versions >= 0.4, but include the fix
// for previous versions as well since 0.4 is still in development / unstable.
// https://github.com/cowboy/grunt/issues/338
// https://github.com/cowboy/grunt/commit/44b57274ceba147e24dcc121ed7d9b84e6ec4e49
if ( parseFloat(grunt.version) < 0.4 ) {
var _readFile = grunt.file.read;
grunt.file.read = function() {
var src = _readFile.apply( this, arguments );
FB::VariantMap PluginTest::test() {
return FB::variant_map_of( "1", "1")( "2", "2" );
}
error C2664: 'std::map<_Kty,_Ty>::map(const std::map<_Kty,_Ty> &)' :
cannot convert parameter 1 from 'FB::detail::VariantMapInserter<T>' to 'const std::map<_Kty,_Ty> &'
// {"error":{"code":"missing-parameters","info":"One ore more required fields were not submitted."}}
$.ajax({
url: "http://testserver/testswarm/api.php?action=addjob",
type: "POST",
dataType: "text",
data: {
authUsername: "dherman",
authToken: "12345",
jobName: "Test Run",
paths: {
// Don't optimize jQuery since it'll be included as a part of our require-jquery script
jquery: "empty:"
},
modules: [
{
name: "lib/require-jquery",
override: {
paths: {
jquery: "lib/jquery-1.7.2"
(function( $ ) {
var createXhr = $.ajaxSettings.xhr;
$.ajaxSettings.xhr = function() {
var xhr = createXhr(),
setRequestHeader = xhr.setRequestHeader;
xhr.setRequestHeader = function( name ) {
if ( name !== "X-Requested-With" ) {
return setRequestHeader.apply( xhr, arguments );
@dcherman
dcherman / array.prototype.polyfills.js
Last active February 10, 2016 20:06
Array.prototype.find and Array.prototype.findIndex polyfills based on the spec at https://gist.github.com/rwldrn/5079427
(function() {
function polyfill( fnName ) {
if ( !Array.prototype[fnName] ) {
Array.prototype[fnName] = function( predicate /*, thisArg */ ) {
var i, len, test, thisArg = arguments[ 1 ];
if ( typeof predicate !== "function" ) {
throw new TypeError();
}