Skip to content

Instantly share code, notes, and snippets.

@bengfarrell
bengfarrell / instance_v_proto.js
Created Aug 7, 2012
Instance vs Prototype definitions
View instance_v_proto.js
/**
* don't know how to use prototype style class defs. It's possible to use method.apply to infer scope,
* however it gets complicated when using 3rd party libs and passing a cb function as a parameter.
* I've seen context wrappers that do this, but it seems overly complicated when I can just use instance style
*/
function InstanceStyleTest() {
var self = this;
this.methodA = function() {
@bengfarrell
bengfarrell / SimpleViewerCustom.java
Created Dec 12, 2012
Customized version of SimpleViewer sample from OpenNI where we combine depth and RGB data
View SimpleViewerCustom.java
/****************************************************************************
* *
* OpenNI 1.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
@bengfarrell
bengfarrell / randomcoords.cpp
Last active Apr 17, 2020
Random Coordinates C++ Node.JS AddOn
View randomcoords.cpp
#include <node.h>
#include <v8.h>
#include <stdio.h>
#include <stdlib.h>
using namespace v8;
Handle<Value> getRandomCoords2D(const Arguments& args) {
HandleScope scope;
View ViiM test
#include <node.h>
#include <v8.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <ViiM/ViiMIncludes.h>
#include <ViiM/core/ViiMTypes.h>
#include "Viim/ViiM.h"
View gist:8777742
app.service('logcat', function() {
var self = this;
//*****************************************************
//* NODE STUFF HERE!
//
var adb = require('adbkit');
var Connection = require('adbkit/lib/adb/connection');
//*****************************************************
@bengfarrell
bengfarrell / gist:11165435
Created Apr 22, 2014
Websocket implementation
View gist:11165435
var WebSocketServer = require('websocket').server;
var http = require('http');
var server = http.createServer(function(request, response) {
console.log((new Date()) + ' Received request for ' + request.url);
response.writeHead(404);
response.end();
});
server.listen(9000, function() {
View gist:b8672aaaeed1dc682a60
var http = require('http');
function getBears(styleId) {
var url = [
"http://google.com",
"/"
].join('');
http.get("http://someurl", function(res) {
var body = '';
@bengfarrell
bengfarrell / gist:4bd75031e40c5dd7202e
Created Sep 19, 2014
Injecting a script into a page using Atom-Shell
View gist:4bd75031e40c5dd7202e
app.on('ready', function() {
var injectscript = escape(__dirname + '/inject/test.js');
mainWindow = new BrowserWindow( { width: '800px', height: '600px', 'web-preferences': { 'web-security': false } });
mainWindow.loadUrl('http://google.com' );
mainWindow.openDevTools();
mainWindow.getWebContents().on('did-finish-load', function() {
var remotejs = "var js = document.createElement('script'); \
js.src = 'file://' + unescape('" + injectscript + "'); \
console.log(js); \
document.getElementsByTagName('body')[0].appendChild(js);";
@bengfarrell
bengfarrell / VO Creation
Created May 5, 2015
Voice over creation with Google Text to Speech
View VO Creation
/**
* Copied from Node-Google-Text-To-Speech module
* https://github.com/ashafir20/node-google-text-to-speech
*
* Altered to not change output to Base64 String, and since I'm
* modifying it for my own purposes, I'll make it more directly tied in
* as a VO creation script
*/
var request = require('request');
@bengfarrell
bengfarrell / gist:f5b519260663af7d8eba
Last active Dec 10, 2015
Making the internet great again: import into the Word Replacer II plugin for Chrome
View gist:f5b519260663af7d8eba
{
"version": "2.0.9",
"replacements": [
{
"repA": "muslim",
"repB": "gun",
"type": "Simple",
"case": "Override",
"active": true
},