Skip to content

Instantly share code, notes, and snippets.

fta2012 / ReplicatedRandomChrome.js
Last active January 15, 2020 05:44
EDIT: This code no longer works on chrome but still works for legacy versions of node. Updated code moved to
View ReplicatedRandomChrome.js
var rngstate;
function MathRandom() {
// Our own implementation of Math.random().
// Source code was copied from
// You need to initialize rngstate with `solve` before this can be used.
// If using node.js, you have to s/18030/18273/g here and in `solve` since they implement it slightly differently:
console.assert(rngstate, "You need to set the global variable `rngstate` first. For example: `rngstate = solve(Math.random(), Math.random());`");
if (!rngstate) return;
var r0 = (Math.imul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
rngstate[0] = r0;
fta2012 / DragTransform
Last active October 9, 2022 15:32
Slightly modified compiled coffeescript from this codepen: Paste into console on a page that has jQuery to load the two dependent libraries (jquery-ui and numericjs). Then call makeTransformable('#selector-name') to make that element WYSIWYG editable. Use inspector to get the CSS for the transforms.
View DragTransform
var selector = 'img' // Replace this with the selector for the element you want to make transformable
jQuery.getScript('//', function() {
jQuery.getScript('//', function() {
(function() {
var $, applyTransform, getTransform, makeTransformable;
$ = jQuery;