Skip to content

Instantly share code, notes, and snippets.

View tommedema's full-sized avatar
🎯
Focusing

Tom Medema tommedema

🎯
Focusing
View GitHub Profile
/* SomeClass.js */
Class("SomeClass", {
use : ["jquery.js", "OtherClass"],
after : {
initialize : function() {
var thisInstance = this;
use("jquery.js", function() {
console.log("Jquery should be loaded here: %o", jQuery);
//TreeNode data structure
Class("DOM.Tree.Node", {
has : {
attributes : {is : "rw", required: true}, //array with DOM.Attributes, excludes stype attribute
styleArr : {is : "rw", required: true}, //style array of the node (attributes with name and value)
name : {is : "rw", required: true}, //name of the node
type : {is : "rw", required: true} //type of the node
}
});
var attributes = [];
if (node.attributes) {
for (var i = 0, iMax = node.attributes.length; i < iMax; i++) {
//set name
var name = node.attributes[i].name;
//validate name
if (typeof(name) != "string") throw "newTreeNode attr name is not a string.";
//exclude style
package com.tommedema.testapp;
import java.util.ArrayList;
import android.app.Service;
import android.content.Intent;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
{
"num_mf_results" : "1",
"num_all_results" : "",
"original_query" : "((exchange:AMEX) OR (exchange:NYSE) OR (exchange:NASDAQ))",
"query_for_display" : "((exchange:AMEX) OR (exchange:NYSE) OR (exchange:NASDAQ))",
"results_type" : "COMPANY",
"searchresults" :
[
{
"title" : "Exxon Mobil Corporation",
//fired when request has been answered
httpRequest.on('response', function (response) {
//set encoding
response.setEncoding('utf8');
//setup output stream
var filePath = 'someFile.csv';
console.log('Now writing: ' + filePath);
var writeStream = fs.createWriteStream(filePath, {
'flags': 'w+',
module.exports = function(server, everyone) {
var util = require('util');
var formidable = require('formidable');
server.post('/upload', function(req, res) {
util.log('/upload request, content type: ' + req.headers['content-type']);
//headers look like eg. 'multipart/form-data; boundary=----pluploadboundaryp15svdal5r1c4ni4610kk1tssa8d4'
var form = new formidable.IncomingForm();
form.keepExtensions = true;
//main.js
var util = require('util');
util.debug('main initializing');
var someMod = require('./someModule')('SomeApp', 'Tom');
someMod.displayAppName();
someMod.displayUserName();
//main.js
var util = require('util');
util.debug('main initializing');
var someMod = require('./someModule')('SomeApp', 'Tom');
someMod.displayAppName();
someMod.displayUserName();
@tommedema
tommedema / uploadNowTest.js
Created April 13, 2011 20:02
Run this: sudo node uploadNowTest.js -> go to http://localhost:3000 in the browser. Select a semi-large file (eg. 3MB) --> upload. When removing the now.js broadcast, this is instant (as it should be, because this is localhost with 0 latency). When broadc
//dependencies:
//node-formidable
//now.js
var formidable = require('formidable'),
http = require('http'),
sys = require('sys'),
util = require('util'),
nowjs = require('now'),
uploadCounter = 0,