Skip to content

Instantly share code, notes, and snippets.

View schell's full-sized avatar
🥑
mmm

Schell Carl Scivally schell

🥑
mmm
View GitHub Profile
/**
* Lists the (at least enumerable) properties of an object.
*
* @param Object the object to list
* @param Number the level to print at (num tabs)
* @param Boolean whether or not to print function code
* @author Schell Scivally
* @since Wed Feb 24 11:10:24 PST 2010
*/
this.dump = function(obj, lvl, pf) {
@schell
schell / public private javascript
Created March 4, 2010 01:03
Javascript closures providing private methods and variables.
var object = function() {
var _privateVariable = 0;
function _privateFunction() {
alert('i am in a closure');
}
function _privateFunctionTwo() {
alert('nothing outside the object created by this function can reach me.');
_privateFunction();
@schell
schell / prettyxml.js
Created March 24, 2010 17:31
Pretty prints xml
/**
* Pretty prints xml
*
* @param String ugly xml
* @return String prettier xml
* @author Schell Scivally
* @since Sun Mar 14 16:16:50 PDT 2010
*/
var formatXml = this.formatXml = function (xml) {
var reg = /(>)(<)(\/*)/g;
/**
* Creates and populates a server with listeners.
*
* @param request http.ServerRequest
* @param response http.ServerResponse
* @author Schell Scivally
* @since Sat Mar 6 18:20:46 PST 2010
*/
var server = http.createServer(function (request, response) {
// put the response in an envelope
(defun filter (a b)
"Filters out all items in a from b"
(if (= 0 (length a)) b
(filter (remove (first a) a) (remove (first a) b))))
@schell
schell / export blender model to javascript object
Created September 8, 2010 10:18
Exports the selected blender object to a javascript object (through the clipboard)
#!BPY
"""
Name: 'isom object'
Blender: 250
Group: 'Export'
Tooltip: 'Exports currently selected object as js file for use with WebGL'
Author: Schell Scivally (efnx.com)
"""
@schell
schell / Point In Polygon
Created January 12, 2011 18:44
Determine whether a point lies within a polygon
//The following code is by Randolph Franklin, it returns 1 for interior points and 0 for exterior points.
int pnpoly(int npol, float *xp, float *yp, float x, float y)
{
int i, j, c = 0;
for (i = 0, j = npol-1; i < npol; j = i++) {
if ((((yp[i] <= y) && (y < yp[j])) ||
((yp[j] <= y) && (y < yp[i]))) &&
(x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
c = !c;
@schell
schell / svn remove deleted
Created February 5, 2011 02:15
removes already deleted (missing) files from svn
svn status | grep ! | cut -c 9- | xargs svn rm
@schell
schell / gist:1057763
Last active September 26, 2015 06:57
JS private methods through closures.
function PrivateThing() {
var privateVar1 = 0;
var privateVar2 = 0;
function privateFunction() {
alert('i am in a closure private var one ='+privateVar1.toString());
privateVar1++;
}
function privateFunctionTwo() {
alert('nothing outside the object created by this function can reach me. private var two ='+privateVar2.toString());
@schell
schell / gist:1068166
Created July 6, 2011 19:47
node compile prob
[~/Code/js/node (master)] ➔ make
Waf: Entering directory `/Users/schellscivally/Code/js/node/build'
DEST_OS: darwin
DEST_CPU: ia32
Parallel Jobs: 2
Product type: program
[33/33] cxx_link: build/default/src/node_main_5.o build/default/src/node_5.o build/default/src/node_buffer_5.o build/default/src/node_javascript_5.o build/default/src/node_extensions_5.o build/default/src/node_http_parser_5.o build/default/src/node_constants_5.o build/default/src/node_events_5.o build/default/src/node_file_5.o build/default/src/node_script_5.o build/default/src/node_os_5.o build/default/src/node_dtrace_5.o build/default/src/node_string_5.o build/default/src/timer_wrap_5.o build/default/src/tcp_wrap_5.o build/default/src/cares_wrap_5.o build/default/src/node_cares_5.o build/default/src/node_net_5.o build/default/src/node_signal_watcher_5.o build/default/src/node_stat_watcher_5.o build/default/src/node_io_watcher_5.o build/default/src/node_stdio_5.o build/default/src/node_child_process_5.o build/default/src/node_timer_5.o build