Skip to content

Instantly share code, notes, and snippets.

@haotian-liu
haotian-liu / express-company.js
Last active February 19, 2020 09:58
A javascript that can differentiate the express IDs of different express companies
var jsoncom = {
'company': [{
'companyname': '申通快递',
'shortname': '申通',
'tel': '95543',
'url': 'st',
'code': 'shentong',
'hasvali': 0,
'comurl': 'http://www.sto.cn',
'isavailable': '0',
import scrapy
import pymysql.cursors
import datetime
from tutorial.items import CKCItem
class CKCSpider(scrapy.Spider):
name = "ckc"
allowed_domains = ["ckc.zju.edu.cn"]
start_urls = [
@haotian-liu
haotian-liu / PolyMorphCount.cpp
Last active October 8, 2017 05:27
Optimized algorithm.
#include <iostream>
#include "gmp.h"
using namespace std;
uint64_t SimpCalc(int Y, int X) {
auto f = new uint64_t[X + 1];
uint64_t sum;
memset(f, 0, sizeof(uint64_t) * (X + 1));
f[1] = 2;
@haotian-liu
haotian-liu / ucf2xdc.php
Created November 6, 2017 08:08
Simple PHP script to convert UCF constraints to XDC
<h3>Convert UCF to XDC</h3>
<?php
$handle = isset($_POST['handle']) && !empty($_POST['handle']) ? $_POST['handle'] : null;
if ($handle === null) {
echo '
<form method="POST">
<textarea name="handle" rows="20" style="width:90%; max-width: 640px"></textarea>
<br>
@haotian-liu
haotian-liu / morning-city.glsl
Created November 28, 2017 11:48
Shader-based animation forked from https://www.shadertoy.com/view/XsBSRG
//#define CARS
#define I_MAX 70
float rand(vec2 n) {
return fract(sin((n.x*1e2+n.y*1e4+1475.4526)*1e-4)*1e6);
}
float noise(vec2 p)
{
p = floor(p*200.0);
@haotian-liu
haotian-liu / sendmail.py
Created October 19, 2018 04:12
Send Email with SMTP using Python
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
mail_host = "smpt.xxxx.com"
mail_user = "sender@xxxx.com"
mail_pass = "password"
@haotian-liu
haotian-liu / script.js
Created December 26, 2018 05:23
Bookmarklet for 19 Fall admission results in 1.3acres
(() => {
const form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "https://www.1point3acres.com/bbs/forum.php?mod=forumdisplay&fid=82&filter=sortid&sortid=164&orderby=dateline");
/* form.setAttribute("target", "view"); */
const hiddenField = (name, value) => {
const field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", name);
field.setAttribute("value", value);
@haotian-liu
haotian-liu / kaomoji.plist
Last active March 8, 2019 15:57
Import this to text substitution in macOS to type kaomoji conveniently with built-in software.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>phrase</key>
<string>˙Ꙫ˙</string>
<key>shortcut</key>
<string>vv</string>
</dict>
@haotian-liu
haotian-liu / list-user-installed-packages.sh
Created June 27, 2019 12:37 — forked from ejona86/list-user-installed-packages.sh
List user-installed packages on LEDE
#!/bin/sh
FLASH_TIME="$(awk '
$1 == "Installed-Time:" && ($2 < OLDEST || OLDEST=="") {
OLDEST=$2
}
END {
print OLDEST
}
' /usr/lib/opkg/status)"
@haotian-liu
haotian-liu / karabiner.json
Created October 22, 2019 18:30
Keep 'spacebar' from being pressed twice
{
"description": "Keep 'spacebar' from being pressed twice",
"manipulators":
[
{
"from": { "key_code": "spacebar" },
"parameters": { "basic.to_if_held_down_threshold_milliseconds": 50 },
"to_if_held_down":[
{
"key_code": "spacebar",