Skip to content

Instantly share code, notes, and snippets.

@upsuper
upsuper / transform.yaml
Last active October 5, 2020 02:46
An example transformation file for translated Simplified Chinese result of 2020 State of Rust survey. See https://github.com/upsuper/csv-transformer
---
- transform: timestamp
column: "C: End time"
header: "Timestamp"
from: "%d-%b-%Y %H:%M:%S"
to: "%d/%m/%Y %H:%M:%S"
- "E: Do you use Rust?"
- "F: How long did you use Rust before you stopped?"
- "G: How long ago did you stop using Rust?"
- transform: join
@upsuper
upsuper / RevokeWoSign_FirefoxOSX.sh
Last active September 28, 2019 08:11
Script to revoke WoSign-related certificates on Firefox for OS X
#!/bin/bash
CERTUTIL="/usr/local/opt/nss/bin/certutil"
if [ ! -f "$CERTUTIL" ]; then
echo "certutil is not found." >&2
echo "You can install it via 'brew install nss'." >&2
exit 1
fi
RCC_DIR=RevokeChinaCerts
@upsuper
upsuper / Cargo.toml
Last active July 11, 2019 10:16
Verify whether there is any MD5 conflict in all possible Chinese mobile numbers https://twitter.com/upsuper/status/1148222832540672001
[package]
name = "cnmobile-md5"
version = "0.1.0"
authors = ["Xidorn Quan <me@upsuper.org>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.release]
lto = true
@upsuper
upsuper / bgmrank.rb
Last active May 14, 2019 03:40
统计 Bangumi 上一个用户的收藏的评分分布情况,已移至 https://github.com/upsuper/bgmrank
#!/usr/bin/env ruby
require 'optparse'
require 'net/http'
CATEGORIES = [:anime, :book, :music, :game, :real]
STATES = [:wish, :collect, :do, :on_hold, :dropped]
progress = true
options = {
@upsuper
upsuper / split-servo.py
Created August 3, 2018 04:23
A filter script of `hg transplant` for coordinated landing for Stylo development
#!/usr/bin/env python
# - * - coding: UTF-8 - * -
import sys
from subprocess import Popen, PIPE
SERVO_PATH = r'c:\\mozilla-source\\servo'
msg = sys.argv[1]
@upsuper
upsuper / convert.c
Last active May 29, 2018 15:34
解包暖暖环游世界中 picData_rw.db 文件的工具代码
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
if (argc < 3) {
printf("usage: %s inputfile outputfile\n", argv[0]);
exit(2);
}

Keybase proof

I hereby claim:

  • I am upsuper on github.
  • I am upsuper (https://keybase.io/upsuper) on keybase.
  • I have a public key ASBKx3KVHC8RM6BT-FdgQRvI3tcyORQ-ctJl8Kwhe9VMdAo

To claim this, I am signing this object:

@upsuper
upsuper / myext.py
Last active January 14, 2016 00:12
Mercurial extension for my local Mozilla repo
# - * - coding: UTF-8 - * -
import re
import os
import os.path
import marshal
from mercurial import cmdutil, patch, revset
from mercurial.error import ParseError
from mercurial.node import bin, hex
@upsuper
upsuper / constants.py
Last active December 31, 2015 14:49
Constants
#!/usr/bin/env python
# - * - coding: UTF-8 - * -
class Constants(object):
__slots__ = ['_d']
def __init__(self, d):
self._d = d
for k, v in self._d.items():
if isinstance(v, dict):
@upsuper
upsuper / progress_indicator.py
Created June 10, 2013 05:52
Graphic progress indicator in command line. It may only support OS X.
#!/usr/bin/python
# - * - coding: UTF-8 - * -
from sys import stdout
from time import sleep
from itertools import cycle
MOON = [u'\U0001F311', u'\U0001F312', u'\U0001F313', u'\U0001F314',
u'\U0001F315', u'\U0001F316', u'\U0001F317', u'\U0001F318']