Skip to content

Instantly share code, notes, and snippets.

View zjn0505's full-sized avatar
🈲
Coding

Charlie Zhang zjn0505

🈲
Coding
  • Shenzhen, China
View GitHub Profile
@zjn0505
zjn0505 / index.js
Last active February 4, 2020 13:32
explainxkcd extraction, deployed on https://xkcd-trans.zjn0505.now.sh/api
'use strict'
const rp = require("request-promise"),
url = require("url"),
cheerio = require("cheerio")
console.log("Init")
module.exports = async (req, res) => {
getMaxFromXkcd()
@zjn0505
zjn0505 / pcm2wav.py
Created August 28, 2019 08:31
Convert PCM to WAV.
import sys
import wave
for arg in sys.argv[1:]:
with open(arg, 'rb') as pcmfile:
pcmdata = pcmfile.read()
wavfile = wave.open(arg+'.wav', 'wb')
# nchannels, sampwidth, framerate, nframes, comptype, compname
wavfile.setparams((1, 2, 16000, 0, 'NONE', 'NONE'))
wavfile.writeframes(pcmdata)
@zjn0505
zjn0505 / search_image.js
Created July 19, 2019 07:25
Tencent Dingdiang NLP fulfillment
const {
buffer,
text,
json
} = require('micro')
const request = require("request")
if (!process.env.KEY || !process.env.CX) {
throw new Error("Missing env KEY or CX");
}
@zjn0505
zjn0505 / ImgInterface.js
Last active July 7, 2019 03:13
xkcd Android app injected scripts
window.addEventListener('load', function(){
Array.from(document.getElementsByClassName('illustration')).forEach(
function(element, index, array) {
var longpress = false;
var presstimer = null;
var startScreenX, startScreenY;
var startWindowScale;
@zjn0505
zjn0505 / ShadeRoot Pastbin.user.js
Created May 31, 2019 15:32
ShadeRoot Pastebin modify
//
// Written by Glenn Wiking
// Script Version: 1.0.0a
// Date of issue: 08/29/17
// Date of resolution: 08/29/17
//
// ==UserScript==
// @name ShadeRoot Pastebin
// @namespace SRPB
// @description Eye-friendly magic in your browser for Pastebin
private void processNluForText(@NonNull final String result) {
Timber.d("processNluForText(String)");
Timber.v(result);
apiAi.query(VoiceServiceStaticHelper.getRequestQueryData(getSessionId(), result, true, sharedPreferencesManager, resourcesLoader))
.compose(this.<ApiAiResponse>processNlpResponse())
.subscribe(new Subscriber<NlpResponse>() {
@Override
public void onCompleted() {
Timber.d("NLP request completed successfully.");
unsubscribe();
private final PublishSubject<Character> testPipeline = PublishSubject.create();
private boolean flag = false;
private test() {
Observable.fromArray('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
.zipWith(Observable.interval(1000, TimeUnit.MILLISECONDS), (character, aLong) -> character)
.flatMap(character -> {
flag = !flag;
if (flag) {