Skip to content

Instantly share code, notes, and snippets.

@quidmonkey
quidmonkey / uninstall_node.sh
Created January 7, 2016 16:55
Uninstall Node
# First:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
#go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@quidmonkey
quidmonkey / bower-components.js
Last active August 29, 2015 14:16
Get All Bower Components in Node
'use strict';
var fs = require('fs');
var globule = require('globule');
var path = require('path');
var bowerComponents = globule
.find('bower_components/**/bower.json')
.map(function (fileName) {
var bowerJson = fs.readFileSync(fileName);
@quidmonkey
quidmonkey / index.html
Last active March 22, 2024 19:05
Three.js Mandelbrot Demo
<!DOCTYPE html>
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/three.js/r67/three.min.js"></script>
</head>
<body>
<script id="mandelbrot-vertex" type="x-shader/x-vertex">
precision highp float;
uniform float zoom;
varying vec2 pos;
@quidmonkey
quidmonkey / JavaScriptExecuter.java
Last active August 29, 2015 14:02
Rhino Example to Execute a Javascript File - Run the following command: "java JavaScriptExecuter test.js"
import java.io.FileReader;
import java.io.Reader;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class JavaScriptExecuter {
public static void main(String[] args) throws FileNotFoundException, ScriptException, NoSuchMethodException {
@quidmonkey
quidmonkey / Gruntfile.js
Last active August 29, 2015 13:59
Changelogs for Grunt
grunt.registerTask('changelog', 'Create git changelog', function () {
var exec = require('child_process').exec;
var path = require('path');
var cmd;
var d = new Date();
var data = grunt.file.readJSON('build.json');
var now = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate(); // yyyy-mm-dd
var since = grunt.option('since') || data.lastSince || now;
var targetFile = path.normalize(__dirname + '/changelogs/changelog_since_' + since + '.txt');
@quidmonkey
quidmonkey / decorator.js
Created March 1, 2014 15:17
Try/Catch Decorator Wrapper for Controller and Adapter/Interface
// controller proxy
for (var key in this.controller) {
if (this.controller.hasOwnProperty(key) && typeof this.controller[key] === 'function') {
this.proxyController(model.controller[key], key);
}
}
MvcAdapter.prototype.proxyController = function (method, key) {
this.controller[key] = function () {
try {
@quidmonkey
quidmonkey / proxy.js
Last active August 29, 2015 13:56
Node Proxy
// need to npm install http-proxy
require('http-proxy').createProxyServer({
port: 80, // if necessary
secure: false, // disable for self-signed certs
target: 'https://www.targetwebsite.com/'
}).listen(9000);
// boom baby, bye-bye development CORS issues!
@quidmonkey
quidmonkey / gist:8886439
Created February 8, 2014 16:42
Position Arrows on Either Side of Carousel
<footer>
<div class="jcarousel">
<ul>
<li><img src="1_designs_tab_images/designs_1.png"></li>
<li><img src="1_designs_tab_images/designs_2.png"></li>
<li><img src="1_designs_tab_images/designs_3.png"></li>
<li><img src="1_designs_tab_images/designs_4.png"></li>
<li><img src="1_designs_tab_images/designs_5.png"></li>
</ul>
</div>
@quidmonkey
quidmonkey / index.html
Last active December 30, 2015 20:19
CSS Beacon - Guarantee that your fonts, images and css are loaded and styling applied.
<!DOCTYPE html>
<html>
<head>
<style>
@-webkit-keyframes beacon {
from { clip: rect(1px, auto, auto, auto); }
to { clip: rect(0px, auto, auto, auto); }
}
.beacon {
-webkit-animation-duration: 0.001s;
@quidmonkey
quidmonkey / gist:6020576
Last active December 19, 2015 21:29
2D Grid-Based, Spatial Partitioning for a Particle System
var grid,
gridSize = { columns 4, rows: 4 };
function createGrid () {
var columns = gridSize.columns,
rows = gridSize.rows,
x,
y;
for (; y < rows; y++) {