Skip to content

Instantly share code, notes, and snippets.

class Singleton {
public:
static Singleton& getInstance()
{
static Singleton instance; // Guaranteed to be destroyed.
// Instantiated on first use.
return instance;
}
private:
Singleton() {}; // Constructor (the {} brackets) are needed here.
@nopjia
nopjia / python-cmd.py
Created September 29, 2014 22:48
Python Command-line
#!/usr/bin/python
import os, sys
def main():
# Command-line Processor
cmd_dir, cmd_name = os.path.split(os.path.abspath(sys.argv[0]))
cmd_args = sys.argv[1:]
@nopjia
nopjia / git-workflow.md
Last active August 29, 2015 14:07
Git Workflow
@nopjia
nopjia / SimpleUpdateLoop.js
Last active August 29, 2015 14:10
SimpleUpdateLoop
var SimpleUpdateLoop = function() {
var _self = this;
var _requestId;
this.onUpdate = function(timestamp) {}; // function to implement
var _update = function(timestamp) {
_self.onUpdate(timestamp);
_requestId = window.requestAnimationFrame(_update);
};
@nopjia
nopjia / loadBufferProgressive.js
Created September 24, 2015 22:59
Progressive ArrayBuffer Loading
var stringToArrayBuffer = function(str, soffset, buf, boffset) {
var ui8a = new Uint8Array(buf, boffset);
for (var si = soffset, ai = 0; si < str.length; si++, ai++)
ui8a[ai] = (str.charCodeAt(si) & 0xff);
};
var loadBufferProgressive = function(url, cb) {
var req = new XMLHttpRequest();
req.open("GET", url);
req.overrideMimeType("text/plain; charset=x-user-defined");
@nopjia
nopjia / basename.js
Created September 25, 2015 00:29
basename & dirname
var basename = function(path) {
return path.replace(/\\/g, "/").replace( /.*\//, "");
};
var dirname = function(path) {
return path.replace(/\\/g, "/").replace(/\/[^\/]*$/, "");
};
@nopjia
nopjia / splitPath.js
Last active November 7, 2022 16:22
The ultimate split path, with a single regex
/**
* The ultimate split path.
* Extracts dirname, filename, extension, and trailing URL params.
* Correct handles:
* empty dirname,
* empty extension,
* random input (extracts as filename),
* multiple extensions (only extracts the last one),
* dotfiles (however, will extract extension if there is one)
* @param {string} path
@nopjia
nopjia / magikarpjump-expert3.sh
Last active October 14, 2018 12:42
ADB bash script for auto-clicking through Magikarp Jump Elite League 3
# Magikarp Jump
# Expert League 3 Automated Clicker
#
# Notes:
#
# All tap positions are hardcoded to my OnePlus3.
# Please re-adjust positions if phone resolution is different.
#
# Any league-triggered event will interrupt this script.
# It is best that level is maxed out before starting the league.
@nopjia
nopjia / magikarpjump-dateloop.sh
Last active January 11, 2018 23:23
ADB bash script for auto-clicking through the date settings exploit in Magikarp Jump
# Magikarp Jump
# Date Settings Exploit Automated Clicker
#
# Instructions:
#
# Connect Android USB Debugging and run in "adb shell".
# Open Android Settings to the Date page and have it be the most recent app.
# Adjust values marked "VARIABLE" accordingly.
# Adjust the number of repetitions as you like.
#
@nopjia
nopjia / magikarpjump-masterleague.sh
Created January 11, 2018 23:27
ADB bash script for auto-clicking through Magikarp Jump Master League
# Magikarp Jump
# Master League Automated Clicker
#
# Notes:
#
# All tap positions are hardcoded to my OnePlus3.
# Please re-adjust positions if phone resolution is different.
#
# Any league-triggered event will interrupt this script.
#