Skip to content

Instantly share code, notes, and snippets.

(function ($) {
/**
* @function
* @property {object} jQuery plugin which runs handler function once specified element is inserted into the DOM
* @param {function} handler A function to execute at the time when the element is inserted
* @param {bool} shouldRunHandlerOnce Optional: if true, handler is unbound after its first invocation
* @example $(selector).waitUntilExists(function);
*/
@0xnbk
0xnbk / aps.js
Last active December 11, 2015 09:59
<script type="text/javascript" src="aps.js"></script>
@0xnbk
0xnbk / aps.js
Last active December 11, 2015 09:59
var _aps = new inAps({
"APS_KEY":"abcd2323283", // APS KEY
"APS_MODE":"development", // development or production
"APS_XML":"http://example.com/config.xml" // Config file
});
@0xnbk
0xnbk / portable-node.md
Created November 9, 2012 07:26 — forked from domenic/portable-node.md
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation

@0xnbk
0xnbk / install-phpunit.sh
Created October 24, 2012 12:03 — forked from scribu/install-phpunit.sh
PHPUnit install script on Ubuntu
#!/bin/bash
sudo apt-get install php-pear
sudo pear upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
@0xnbk
0xnbk / mongodb.monitrc
Created October 11, 2012 07:09 — forked from durran/mongodb.monitrc
MongoDB Monit Config
check process mongodb
with pidfile "/var/lib/mongodb/mongod.lock"
start program = "/sbin/start mongodb"
stop program = "/sbin/stop mongodb"
if failed port 28017 protocol http
and request "/" with timeout 10 seconds then restart
if 5 restarts within 5 cycles then timeout
@0xnbk
0xnbk / gist:2841152
Created May 31, 2012 04:58
Android Phonegap
function capture() {
// Retrieve image file location from specified source
navigator.camera.getPicture(getImageURI, function(message) {
alert('Image Capture Failed');
}, {
quality : 40,
destinationType : Camera.DestinationType.FILE_URI
});
@0xnbk
0xnbk / phonegap-photofetcher.js
Created May 29, 2012 05:37 — forked from brianleroux/phonegap-photofetcher.js
PhoneGap Convert Photo File URI to Data URI
function getPhoto() {
navigator.camera.getPicture(onPhotoSuccess, onPhotoFail,
{quality: 70, targetWidth: 500, targetHeight: 500,
sourceType: navigator.camera.SourceType.PHOTOLIBRARY,
destinationType: navigator.camera.DestinationType.FILE_URI,
});
}
function onPhotoSuccess(imageUri) {
var $img = $('<img/>');
@0xnbk
0xnbk / favicon-interceptor.js
Created February 20, 2012 08:57 — forked from kentbrew/favicon-interceptor.js
How to short-circuit those annoying favicon requests in node.js
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
@0xnbk
0xnbk / .css
Created January 28, 2011 09:04
Perfect Full Page Background Image [CSS3]
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}