This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pycxsimulator | |
from pylab import * | |
n = 200 # size of grid: n * n | |
Dh = 1. / n # spatial resolution, assuming space is [0,1] * [0,1] | |
Dt = 0.02 # temporal resolution | |
a, b = 12.0, 16.0 # parameter values | |
Du = 0.0001 # diffusion constant of u |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////////////////////// | |
// Lightning component code to listen for post message commands from | |
// visualforce pages. It would be very very VERY helpful if this functionality | |
// was provided by the core lightning ui code. | |
///////////////////////////////////////////////////////////////////////////////////////// | |
({ | |
setupLightningConverterListener: function(){ | |
var listener = function(event) { | |
if(event.data.action === 'toast'){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeMockRedisClient(listener){ | |
var calls = []; | |
return { | |
on: function(){ | |
if(listener){ listener('on', arguments); } | |
calls.push({name: 'on', args: arguments}); | |
}, | |
hget: function(key, index, callback){ | |
if(listener){ listener('hget', arguments); } | |
calls.push({name: 'hget', args: arguments}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function genericXmlParser(xml, callback){ | |
var parser = new xml2js.Parser(); | |
var isParseError = true; | |
try | |
{ | |
parser.parseString(xml, function(err,obj){ | |
isParseError = false; | |
if(err){ | |
callback({error: 'XML Parsing Error'}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
//A Preprocessor Macro for iterating | |
#define FOR_EACH(array, type, block) { \ | |
int len = sizeof(array)/sizeof(type);\ | |
for(int i=0; i<len; i++){ \ | |
type this = array[i]; \ | |
block \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isAdditive(f,x,y){ | |
return ((f(x) + f(y)) === f(x+y)); | |
} | |
function everyCombinationOfTwo(arr){ | |
var toreturn = []; | |
arr.forEach(function(first){ | |
arr.forEach(function(second){ | |
toreturn.push([first,second]); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var topologicalSort = require('./topologicalsort').topologicalSort; | |
tests = [ | |
{ | |
graph: [ | |
{edges:[1,2]}, | |
{edges:[3]}, | |
{edges:[5]}, | |
{edges:[4]}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function traverse(obj,func, parent) { | |
for (i in obj){ | |
func.apply(this,[i,obj[i],parent]); | |
if (obj[i] instanceof Object && !(obj[i] instanceof Array)) { | |
traverse(obj[i],func, i); | |
} | |
} | |
} | |
function getPropertyRecursive(obj, property){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function js2xml(js, wraptag){ | |
if(js instanceof Object){ | |
return js2xml(Object.keys(js).map(function(key){return js2xml(js[key], key);}).join('\n'), wraptag); | |
}else{return ((wraptag)?'<'+ wraptag+'>' : '' ) + js + ((wraptag)?'</'+ wraptag+'>' : '' );} | |
} | |
//try it | |
var output = js2xml({ | |
boosh: '1', | |
is: '2', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeSortedObject(obj, casesensitive){ | |
return Object.keys(obj).map(function(key){ | |
return {key: key, value: obj[key]}; | |
}).sort(function(a,b){ | |
return (casesensitive? a.key : a.key.toLowerCase()) > (casesensitive? b.key : b.key.toLowerCase()); | |
}); | |
} |
NewerOlder