Skip to content

Instantly share code, notes, and snippets.

View hotpxl's full-sized avatar

Yutian Li hotpxl

View GitHub Profile
@hotpxl
hotpxl / ipv6.sh
Last active December 25, 2015 01:19
Connect to Tsinghua ISATAP
#!/bin/bash
if [[ -z "$1" ]]; then
INTERFACE=(en0 en4)
else
INTERFACE=$1
fi
for ITEM in ${INTERFACE[*]}; do
echo "Trying interface ${ITEM}"
LOCAL_IP=$(ifconfig ${ITEM} | grep inet | grep -v inet6 | awk '{print $2}')
@hotpxl
hotpxl / prepare-commit-msg
Last active March 5, 2018 21:52
Prepare commit message for Git
#!/usr/bin/env bash
set -euo pipefail
branch=$(git symbolic-ref HEAD | sed -e "s#refs/heads/##")
sed -i.sed '1 i \
'"[${branch}] " "$1"
@hotpxl
hotpxl / swap-ctrl-caps.reg
Last active April 23, 2020 19:13
Swap control and caps lock on Windows
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00
@hotpxl
hotpxl / depot-using-monitor.c
Created April 23, 2014 14:30
Monitor solution for Chapter 2 Exercise 1 Extension 1 from 操作系统之PV金典
#include <stdio.h>
#include <proc.h>
#include <sem.h>
#include <monitor.h>
#define N 3
#define M 4
#define TIMES 10
int numberA;
@hotpxl
hotpxl / IDS.py
Last active August 29, 2015 14:07
from scapy.all import *
from random import randint
payload = 'GET /proxy.org HTTP/1.1\r\nUser-Agent: curl/7.35.0\r\nHost: mit.edu\r\n\r\n'
ip = '23.66.32.128'
sport = randint(30000, 50000)
if __name__ == '__main__':
@hotpxl
hotpxl / dvorak.reg
Last active April 26, 2019 07:53
Dvorak keyboard layout for Windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"ScanCode Map"=hex:00,00,00,00,00,00,00,00,22,00,00,00,2d,00,30,00,24,00,2e,00,\
11,00,33,00,33,00,11,00,12,00,20,00,34,00,12,00,1b,00,0d,00,0d,00,1b,00,16,\
00,21,00,17,00,22,00,20,00,23,00,1a,00,0c,00,2e,00,17,00,23,00,24,00,14,00,\
25,00,31,00,26,00,35,00,1a,00,30,00,31,00,13,00,18,00,26,00,19,00,2f,00,34,\
00,28,00,10,00,0c,00,28,00,19,00,13,00,18,00,1f,00,1f,00,27,00,2c,00,35,00,\
15,00,14,00,22,00,16,00,25,00,2f,00,10,00,2d,00,21,00,15,00,27,00,2c,00,00,\
00,00,00
@hotpxl
hotpxl / change_backlight
Created August 5, 2015 12:40
Utilities for laptop access
#!/usr/bin/zsh
case "$1" in
+)
ACTION="-inc";;
-)
ACTION="-dec";;
*)
echo "invalid option";
exit 1;;
@hotpxl
hotpxl / log.py
Last active May 19, 2016 03:44
Logging utilities
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Logging utilities."""
import logging
CRITICAL = logging.CRITICAL
ERROR = logging.ERROR
WARNING = logging.WARNING
INFO = logging.INFO
DEBUG = logging.DEBUG
@hotpxl
hotpxl / get-sshfp.sh
Created September 8, 2016 07:12
Get SSHFP record
#!/bin/bash
set -euo pipefail
print_usage() {
printf "Usage: %s <fully qualified domain names>...\n" "$(basename "$0")"
exit 1
}
if [[ "$#" -lt 1 ]]; then
print_usage
@hotpxl
hotpxl / README.md
Last active March 2, 2017 14:21
MinPy next step prototype

MinPy Next Step Prototype

Run it with Python 3. Not tested with Python 2 and most probably will not run for now.

This just shows how JIT and gradient code generation works together. Execution and optimization are just placeholders. They will be hooked to NNVM.