Skip to content

Instantly share code, notes, and snippets.

Avatar

Chunliang Lyu cllu

View GitHub Profile
@cllu
cllu / aync-http-requests.py
Created Dec 11, 2014
Python 3 asynchronous HTTP request with aiohttp and asyncio
View aync-http-requests.py
import asyncio
import aiohttp
def _crawl_url(url):
try:
resp = yield from asyncio.wait_for(aiohttp.request('GET', url, allow_redirects=True), 10)
""":type resp: aiohttp.client.ClientResponse"""
resp.text = yield from asyncio.wait_for(resp.text(), 10)
return resp
View wechat2txt.py
import os
import sys
import re
import hashlib
import csv
import time
import locale
import getopt
@cllu
cllu / README.md
Last active Nov 25, 2015
LeetCode OJ Tampermonkey script
View README.md

LeetCode OJ modifier

  • hide the LeetCode Premium Subscription and Books links on the top navigation bar, since I have already subscribed.
  • hide the chat link, hide the footer
  • hide the FAQ block on the right column for the discussion page
  • display the question id on the problem page
  • display number of solved/total problems on the /company/ page
@cllu
cllu / hn_seach.js
Last active Dec 9, 2015 — forked from meiamsome/hn_search.js
HackerNews Who is Hiring TamperMonkey Script
View hn_seach.js
// ==UserScript==
// @name HackerNews WhosHiring
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://news.ycombinator.com/item?id=*
// @grant none
// ==/UserScript==
/* jshint -W097 */
View stanford-nlp-socket.md

Making use of the Stanford NLP Socket Server

Stanford NER tagger can be started listening to socket easily, which is documented as in the README file.

java -mx1000m -cp $HOME/resources/stanford/tagger/stanford-ner.jar edu.stanford.nlp.ie.NERServer -loadClassifier $HOME/resources/stanford/tagger/classifiers/english.all.3class.distsim.crf.ser.gz -port 1234

The POS tagger also has a built-in MaxentTaggerServer, however, we cannot directly use it.

@cllu
cllu / cllu_pinyin.dict.yaml
Last active Jan 11, 2016
Rime Custom Schema
View cllu_pinyin.dict.yaml
# Rime dictionary
# encoding: utf-8
---
name: cllu_pinyin
version: "2014.12.24"
sort: by_weight
use_preset_vocabulary: true
# import dict from luna_pinyin.dict.yaml
import_tables:
View markdown draft-js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Draft • Decorators</title>
<link rel="stylesheet" href="../../dist/Draft.css" />
</head>
<body>
<div id="target"></div>
<script src="../../node_modules/react/dist/react.js"></script>
@cllu
cllu / CustomParser.php
Last active Mar 31, 2016
MediaWiki custom parser
View CustomParser.php
<?php
# Confirm MediaWiki environment
if (!defined('MEDIAWIKI')) die();
# Credits
$wgExtensionCredits['other'][] = array(
'name'=>'CustomParser',
'author'=>'Chunliang Lyu',
'url'=>'https://www.mediawiki.org/wiki/Extension:CustomParser',
@cllu
cllu / index.html
Created Jul 8, 2016
Reveal.js for MediaWiki
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reveal.js – The HTML Presentation Framework</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
@cllu
cllu / README.md
Last active Sep 25, 2016
GitHub Wiki TamperMonkey script
View README.md

GitHub Wiki TamperMonkey script

  • add word count
  • remove unused stuff
  • add Table of Content to the right column
  • Add keyboard shortcuts: double click content area to edit

The script matches only wikis on my own GitHub repos, change it according to your preferences:

You can’t perform that action at this time.