Skip to content

Instantly share code, notes, and snippets.

@kmxz
kmxz / handle.json
Last active March 16, 2024 01:15
存档
'{"handle-uid":"kaelaAhGMyguezAcCpdBw","handle-initialized":"true","handle-number-tone":"false","handle-colorblind":"false","debug":"honey:core-sdk:*","handle-check-assist":"true","handle-tries-meta":"{\\"30\\":{\\"tries\\":[\\"王八犊子\\",\\"地大物博\\",\\"地动山摇\\"],\\"start\\":1643530525989,\\"hint\\":true,\\"passed\\":true,\\"end\\":1643531129278,\\"sent\\":true},\\"31\\":{\\"tries\\":[\\"蜜雪冰城\\",\\"肛门干燥\\",\\"纸上谈兵\\"],\\"hint\\":true},\\"34\\":{\\"tries\\":[\\"提前射精\\",\\"深入浅出\\",\\"气势如虹\\",\\"好为人师\\",\\"虎进猴山\\",\\"虎吃冰沙\\",\\"虎赠花生\\",\\"虎父亲生\\",\\"虎虎风生\\"]},\\"35\\":{\\"tries\\":[\\"虎啸风生\\",\\"如狼似虎\\",\\"放狗追虎\\",\\"绿猫黄虎\\",\\"如虎似狼\\",\\"购虎防驴\\",\\"大虎藏林\\",\\"卧虎藏龙\\"],\\"start\\":1643961600384,\\"passed\\":true,\\"end\\":1643964743921,\\"sent\\":true},\\"36\\":{\\"tries\\":[\\"力不从心\\",\\"扶她那里\\",\\"虎皮青椒\\",\\"虎啸山庄\\",\\"虎弟弯叔\\",\\"虎势堪忧\\",\\"虎视眈眈\\"],\\"start\\":1644049142705,\\"hint\\":true,\\"passed\\":true,\\"end\\":1644050138547,\\"sent\\":true},\\"37\\":{\\"tries\\":[\\"骑虎难下\\",\\"江河日下\\",\\"瓜田李下\\"],\\"duratio
@kmxz
kmxz / run-in-browser-console.js
Created January 7, 2019 04:37
Script to add to gartic.io
const assertEqual = (a, b, opt_msg) => {
if (a !== b) {
throw new RangeError((opt_msg || 'Assertion failed') + ' (expected: ' + b + '; actual: ' + a + ')');
}
};
const verifyWords = words => {
const lines = words.split('\n').filter(_ => _).map(_ => _.trim());
assertEqual(lines.shift(), 'Word,Difficulty (1 - 3),Dirtyness (1 - 3)');
@kmxz
kmxz / thin-svg.js
Created May 31, 2016 11:53
Reduce the size of SVG files exported from Sketch
#!/usr/bin/env node
var DOMParser = require('xmldom').DOMParser;
var fs = require("fs");
var file = fs.readFileSync(process.argv[2], 'utf-8');
var doc = new DOMParser().parseFromString(file, 'text/xml');
var regex = /^\s*translate\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)\s*$/;
// pass 1: remove IDs
@kmxz
kmxz / debug.js
Last active March 18, 2016 03:10
滑上上下下左右左右开启 debug
(function () {
var buffer = [];
window.addEventListener('error', function (ee) {
addResult({
source: 'window.onerror',
stack: ee.error ? ee.error.stack : (ee.filename + ':' + ee.lineno + ':' + ee.colno),
message: ee.message
});
});
['error', 'warn', 'log', 'info'].map(function (verb) {
@kmxz
kmxz / svg2png.js
Created November 27, 2015 11:33
The designer gave me SVG images exported from PhotoShop, which cannot be supported by Android Studio. So I wrote this script to convert SVG to PNGs of different sizes needed in Android projects.
#!/usr/bin/phantomjs
var fs = require('fs');
var system = require('system');
var webPage = require('webpage');
var args = system.args;
if (args.length != 4) {
console.error('ERROR: Please specify 3 arguments: [input svg file], [res directory] and [output image width (mdpi)].');
@kmxz
kmxz / toDom$.js
Last active August 29, 2015 14:27
A tool to convert a HTML fragment to a section of JavaScript to create it using Dom.$
/**
* @param{HTMLElement} root
* @param{number} prettyPrint - indent width; 0 for no pretty-print
* @param{string} func - the name of the function to be called. for example, "Dom.$"
* @param{boolean} allVar - name all elements as variables
* @param{boolean} omitSpace - trim all text nodes
*/
var toDom$ = function (root, prettyPrint, func, allVar, omitSpace) {
var table = [];
@kmxz
kmxz / 1-10.clj
Last active August 29, 2015 14:22
99 Problems in Clojure
; P01 - general version for lists and vectors
(defn p01 [l]
(let [n (next l)]
(if (nil? n) (first l) (recur n))
)
)
; P01 - use destructing assignment, works for lists and vectors
(defn p01' [l]
(let [[head & rest] l]
@kmxz
kmxz / gist:8a10690effc5656f8e7e
Created January 11, 2015 19:13
Naive function plotter
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://bootswatch.com/paper/bootstrap.min.css" />
<style type="text/css">
.template {
display: none;
}
</style>
<script type="text/javascript">
var add, addListeners, conf, getColor, getGray, init, initconfAndSetListeners, mathWrapX, maxOfArray, minOfArray, randShift, reAssign, reRender, toArray;
@kmxz
kmxz / postimg.user.js
Created October 11, 2013 17:04
Show full size imgs for postimg.org instead of thumbs
// ==UserScript==
//
//Displayable Name of your script
// @name Postimg handler
// @include *extreme-board.com/*
//
// ==/UserScript==
function get_further(rt) {
var mt = /<img[^<>]*src='([^<>']+)'[^<>]*\/>/;