Skip to content

Instantly share code, notes, and snippets.

@Hexcles
Hexcles / url_base64.php
Last active August 29, 2015 13:56
URL安全的Base64编码(用'-'代替'+',用'_'代替'/',去掉末尾的padding),PHP实现
<?php
// public url_base64_encode(bin) {{{
/**
* url_base64_encode 生成URL安全的Base64编码
*
* @param string $bin
* @access public
* @return string
*/
@Hexcles
Hexcles / urldecode.py
Last active August 29, 2015 14:10
Rename urlencoded (quoted) filenames
#!/usr/bin/env python3
from sys import argv
from os import path, system
from urllib.parse import unquote
if len(argv) == 1:
print("Usage: urldecode.py FILES...")
exit
@Hexcles
Hexcles / up.sh
Created March 24, 2012 12:41
Setting up DNS according to OpenVPN dhcp-option (used with openvpn --up)
#!/bin/sh
# Setting up DNS according to OpenVPN dhcp-option
# used with openvpn --up
mv /etc/resolv.conf /etc/resolv.conf.old
for (( i=1; 1; i++))
do
optname="foreign_option_$i"
option=${!optname}
@Hexcles
Hexcles / down.sh
Created March 24, 2012 12:41
Restore original DNS settings (used with openvpn --down)
#!/bin/bash
# Restore original DNS settings
# used with openvpn --down
if [ -f /etc/resolv.conf.old ]
then
rm /etc/resolv.conf
mv /etc/resolv.conf.old /etc/resolv.conf
echo "resolv.conf restored"
fi

Keybase proof

I hereby claim:

  • I am Hexcles on github.
  • I am hexcles (https://keybase.io/hexcles) on keybase.
  • I have a public key whose fingerprint is D702 16BF 9E85 ACDF 713D 239B 9BB2 B9D1 6044 A8E7

To claim this, I am signing this object:

@Hexcles
Hexcles / LICENSE
Created July 20, 2017 21:28
[chromium] Convert W3CImportExpectations to OWNERS files
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
@Hexcles
Hexcles / vpn-dorm.sh
Created September 14, 2013 15:15
ZJU Zijingang Campus dormitory VPN dial up script (xl2tpd + systemd, for Archlinux)
#!/bin/bash
PPP_TIMEOUT=30
L2TPD_TIMEOUT=5
L2TPD_CONTROL_FILE=/var/run/xl2tpd/l2tp-control
VPN_ACCOUNT=zjuvpn
function start_xl2tpd
{
systemctl start xl2tpd
@Hexcles
Hexcles / wpt-import-stats.py
Created September 25, 2017 23:21
wpt-import-stats.py
#!/usr/bin/python2
# Requirements: numpy & dateutil ( sudo apt install python-{numpy,dateutil} )
from __future__ import print_function
from collections import defaultdict, namedtuple
import dateutil.parser
import json
import re
import numpy
import os
@Hexcles
Hexcles / wpt-export-stats.py
Last active September 25, 2017 23:22
WPT Export Stats
#!/usr/bin/python2
# Based off https://gist.github.com/jeffcarp/f1fb015e38f50e82d30b8c69b67faa74
# Requirements: numpy & requests ( sudo apt install python-{numpy,requests} )
from __future__ import print_function
from datetime import datetime
import csv
import collections
import json
import numpy
@Hexcles
Hexcles / find_dupes.py
Last active November 14, 2017 21:18
Simple LayoutTests global baseline optimization
from __future__ import print_function
from collections import defaultdict
import hashlib
import re
def main():
baselines = defaultdict(dict)
f = open('baselines', 'r')
regexp_head = re.compile(r'^\./(platform/[^/]+/)')