Skip to content

Instantly share code, notes, and snippets.

View huan's full-sized avatar
💭
ChatOps!

Huan Li huan

💭
ChatOps!
View GitHub Profile
@adielBm
adielBm / ipa-for-google-translate.js
Last active May 1, 2024 14:23
ipa for google-translate
function getIPA(str) {
const mapping = {
"oi": "ɔɪ",
"ou": "aʊ",
"ô": "ɔ",
"ä": "ɑ",
"a": "æ",
"æʊ": "aʊ",
"i": "ɪ",
"ē": "i",
const XState = require('xstate')
const { Machine, interpret } = XState
const { raise } = XState.actions
/*
run from cli using:
node xstate-onentry-timing-bug.js [sync|async|raise]
*/
@oleavr
oleavr / jit-example.js
Created January 27, 2019 20:18
Frida JIT example
'use strict';
const slowCallback = new NativeCallback(value => {
console.log('slowCallback hit');
return 43;
}, 'int', ['int']);
const fastCallback = Memory.alloc(Process.pageSize);
Memory.patchCode(fastCallback, 128, code => {
const cw = new X86Writer(code, { pc: fastCallback });
@oleavr
oleavr / QuakeRESTAPIDemo.md
Last active July 6, 2021 19:04
Quake REST API demo

Build

npm install

Run

$ frida QuakeSpasm --enable-jit -l _agent.js
$ curl -s http://localhost:1337/stats | jq
$ curl -s -X POST http://localhost:1337/attack | jq
@max-mapper
max-mapper / bibtex.png
Last active March 10, 2024 21:53
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png
@developit
developit / async-examples.js
Last active February 19, 2020 00:43
Async Array utilities in async/await. Now available as an npm package: https://github.com/developit/asyncro
/** Async version of Array.prototype.reduce()
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => {
* acc[v] = await (await fetch(v)).json();
* return acc;
* }, {});
*/
export async function reduce(arr, fn, val, pure) {
for (let i=0; i<arr.length; i++) {
let v = await fn(val, arr[i], i, arr);
if (pure!==false) val = v;
@snakevil
snakevil / router.pi-2.md
Last active September 27, 2023 02:25
使用树莓派3B打造超强路由之二:初成

使用树莓派3B打造超强路由之二:初成

通过第一篇《使用树莓派3B打造超强路由之一:初装》的努力,树莓派3B已经可以作为一台超低能耗、随身携带的开发用服务器来使用了。但这对于目标——打造超强路由而言,才刚刚开始。接下来,我们需要将其打磨成一台基本的无线路由器。

WARNING 本文所有指令均仅供参考,切勿无脑复制粘贴!

@mogsdad
mogsdad / Apps Script pdfToText utility.md
Last active April 10, 2024 01:38
For http://stackoverflow.com/questions/26613809, a question about getting pdf attachments in gmail as text. I got a little carried away - this does much more than asked.

Google Apps Script pdfToText Utility#

This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).

Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.

    // Start with a Blob object
    var blob = gmailAttchment.getAs(MimeType.PDF);
    
@andrew8088
andrew8088 / stringify.js
Last active August 23, 2022 07:54
A simple implementation of JSON.stringify; covers every case I could think of
function stringify(obj) {
if (typeof obj !== 'object' || obj === null || obj instanceof Array) {
return value(obj);
}
return '{' + Object.keys(obj).map(function (k) {
return (typeof obj[k] === 'function') ? null : '"' + k + '":' + value(obj[k]);
}).filter(function (i) { return i; }) + '}';
}
@risacher
risacher / main.js
Created July 1, 2014 02:23
glue to make blessed (low-level API) work in browserify with term.js
var blessed = require("blessed");
window.onload = function () {
var term = new Terminal({
cols: 80,
rows: 24,
useStyle: true,
screenKeys: true
});