Skip to content

Instantly share code, notes, and snippets.

@psema4
psema4 / rename-tiles-to-sprites.sh
Created November 2, 2019 23:02
search and replace in filenames
# Search and replace filenames in the current directory
#
# Example:
# tile-000.png
# tile-001.png
# tile-002.png
#
# becomes
# sprite-000.png
# sprite-001.png
@psema4
psema4 / reset.js
Created June 21, 2019 17:46 — forked from 19h/reset.js
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}
@psema4
psema4 / CreateJob.sh
Created December 3, 2018 13:51 — forked from stuart-warren/CreateJob.sh
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
@psema4
psema4 / events.js
Created October 23, 2018 13:44 — forked from tbranyen/events.js
Rethinking events using ES6 (https://tbranyen.com/events)
const bus = {};
const get = e => (bus[e] = bus[e] || new Set());
export const listeners = new Proxy(bus, { get });
export const emit = (e, ...args) => listeners[e].forEach(fn => fn(...args));
@psema4
psema4 / simpleSequencer.js
Created August 24, 2018 03:55
A simple webaudio sequencer
class SimpleSequencer {
/* SimpleSequencer essentially combines the following tutorials and wraps them in es6
*
* https://github.com/kylestetz/Web-Audio-Basics/tree/gh-pages/4-Continuous-Sequencing
* https://www.html5rocks.com/en/tutorials/audio/scheduling/
* http://clockworkchilli.com/blog/3_html5_drum_machine_with_web_audio
*
*
* Usage:
@psema4
psema4 / gist:a8003f1f09d77743e85750e6aefb7a65
Created August 8, 2018 04:06 — forked from borismus/gist:1032746
Convert a base64 string into a binary Uint8 Array
var BASE64_MARKER = ';base64,';
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(i = 0; i < rawLength; i++) {
@psema4
psema4 / prover.js
Created May 20, 2017 17:56 — forked from othiym23/prover.js
Simple proof-of-work server for Node.js.
'use strict';
/* To test:
* echo -n <input> | nc localhost 1337
*
* Results are <input>:<nonce>
*
* Passing e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e should get back
* e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e:2c8
*/
@psema4
psema4 / msws-common.js
Last active July 30, 2023 09:35
Simple Middle Square Weyl Sequence PRNG
/* Simple PRNG Based on https://en.wikipedia.org/wiki/Middle-square_method#Middle_Square_Weyl_Sequence_RNG
*
* Usage:
* node:
* var MSWS = require('msws.js');
*
* browser:
* include this script in your html document
*
* both:
@psema4
psema4 / get-unity-packages-as-json-bookmarklet.html
Created April 11, 2017 01:23
Unity Asset Store Bookmarklet
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<h1>Get Unity Packages as JSON</h1>
<p>Retrieves basic information about your Unity Asset Store assets in JSON format.</p>