Skip to content

Instantly share code, notes, and snippets.

View Spaxe's full-sized avatar
🏹

Xavier Ho Spaxe

🏹
View GitHub Profile
@Spaxe
Spaxe / pixelio.py
Created April 7, 2011 15:45
Pixel.io's crytarithm brute force solution
# WWW * GPU = PIXEL I/O
# X = 6
# O != 1
from itertools import permutations
for digits in permutations(d for d in range(10) if d != 6):
W, G, P, U, I, E, L, O = digits[:8]
if (O != 1 and O * (W*100+W*10+W) * (G*100+P*10+U) == (P*100000+I*10000+6000+E*100+L*10+I)):
print ("{}{}{} * {}{}{} = {}{}6{}{} {}/{}".format(W, W, W, G, P, U, P, I, E, L, I, O))
@Spaxe
Spaxe / printRunCommandOptions.js
Created November 11, 2011 06:37
Print all available options for MongoDB's db.runCommand()
// Prints all available command from db admin, db.runCommand options
// Usage: mongo < printRunCommandOptions.js
use admin;
for (var cmd in db.getCollection("$cmd")) {
print(cmd);
}
@Spaxe
Spaxe / mobile-detect.js
Created February 8, 2012 12:16
Detecting Mobile devices with Javascript
function TouchScreenAdapt()
{
if (typeof TouchEvent != "undefined")
{
$('body').removeClass('mouse').addClass('touch');
}
}
@Spaxe
Spaxe / audio.js
Created April 11, 2012 04:44
Quick and dirty way of selectively loading a playable audio file in HTML5
// Because HTML5 Audio support isn't all that consistent, we need to do something.
// With at least both .ogg and .mp3 formats, they will play on all 5 major
// browsers on the desktop.
// XXX If more ancient support is desired, feel free to add <embed> support. Or Flash.
//
// sources should be a list of audio files of the same sound, but in different formats.
// e.g.: ['effect.ogg', 'effect.mp3', 'effect.wav']
// Depending on the browser capability, it will only add one of them that is playable.
// If no compatible format is found for that browser, a warning will be issued.
// List of Audio MIME Types:
@Spaxe
Spaxe / gist:5037598
Last active December 14, 2015 05:48
Setup steps for @0x17 on Mac OS X 10.8
Take original image A, blur it to get image B. Then:
(A-B) * effectStrength + A
gives you output with lots more apparent detail.
It boosts contrast against surrounding pixels. A blur kernel with 1 pixel radius is equivalent to standard pixel sharpening, bigger blurs give a better effect but produce haloes around objects. You need a smarter blur that preserves edges to remove them.
@Spaxe
Spaxe / MatImage.pde
Created September 18, 2014 06:32
OpenCV cv::Mat <==> Processing PImage Converter Functions
import java.nio.*;
import org.opencv.core.Mat;
import org.opencv.core.CvType;
// Convert PImage (ARGB) to Mat (CvType = CV_8UC4)
Mat toMat(PImage image) {
int w = image.width;
int h = image.height;
Mat mat = new Mat(h, w, CvType.CV_8UC4);
@Spaxe
Spaxe / .jshintrc
Created March 12, 2015 04:01
JSHint Options for p5js
{
// The plugin looks for a .jshintrc file in the same directory as the source
// file you're prettifying (or any directory above if it doesn't exist, or in
// your home folder if everything else fails) and uses those options along
// the default ones.
// Details: https://github.com/victorporof/Sublime-JSHint#using-your-own-jshintrc-options
// Example: https://github.com/jshint/jshint/blob/master/examples/.jshintrc
// Documentation: http://www.jshint.com/docs/options/
"browser": true,
@Spaxe
Spaxe / p5js-browserfy-example.js
Created March 13, 2015 00:11
p5js with browserfy
// Thanks to @brysonian
// https://github.com/processing/p5.js/issues/522#issuecomment-78510817
var p5 = require("p5");
var myp5 = new p5(function( sketch ) {
sketch.setup = function() {
var cnv = sketch.createCanvas(500, 500);
sketch.colorMode(sketch.HSB, 360, 100, 100);
sketch.noStroke();
};
@Spaxe
Spaxe / gitter-p5js-email
Last active August 29, 2015 14:17
Adding processing/p5.js to Gitter Chatroom
Hey p5js people,
I recently started using p5.js. After transitioning from Processing to
Prcoessing.py, p5.js seems like a good step to go. Thanks for making this
possible, and I expect to be contributing to the Github page soon.
At the moment there aren't a lot of real-time conversation places for p5.js. I
have found the Education Page, the Forum, and of course the GitHub Issues page.
There are great, searchable resources, but no direct access to human resources.