Skip to content

Instantly share code, notes, and snippets.

@glacjay
glacjay / tun-ping-win.py
Created September 19, 2010 16:24
Reading/Writing OpenVPN's TUN/TAP Device under Windows using Python.
import _winreg as reg
import win32file
adapter_key = r'SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}'
def get_device_guid():
with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, adapter_key) as adapters:
try:
@glacjay
glacjay / tun-ping-linux.py
Created September 18, 2010 04:49
Reading/writing Linux's TUN/TAP device using Python.
import fcntl
import os
import struct
import subprocess
# Some constants used to ioctl the device file. I got them by a simple C
# program.
TUNSETIFF = 0x400454ca
TUNSETOWNER = TUNSETIFF + 2
@glacjay
glacjay / tun-ping-mac.py
Created September 19, 2010 15:59
Reading/writing Mac's TUN/TAP device using Python.
import os
import subprocess
# Open file corresponding to the TUN device.
tun = open('/dev/tun0', 'r+b')
# Bring it up and assign addresses.
subprocess.check_call('ifconfig tun0 192.168.7.1 192.168.7.2 up', shell=True)
@glacjay
glacjay / tun-ping-linux.go
Created September 18, 2010 12:26
Reading/Writing Linux's TUN/TAP device in Go.
package main
import (
"exec"
"log"
"os"
"syscall"
"unsafe"
)
@glacjay
glacjay / tun-ping-mac.go
Created September 19, 2010 16:03
Reading/Writing Mac's TUN/TAP device using Go.
package main
import (
"exec"
"log"
"os"
)
func main() {
file, err := os.Open("/dev/tun0", os.O_RDWR, 0)
- DOMAIN-SUFFIX, google.com, Proxy
- IP, 104.154.127.126, Spotify
// ==UserScript==
// @name youtube playlist cleaner
// @namespace http://tampermonkey.net/
// @version 0.2
// @description add a filter button to filter out watched videos
// @author GlacJAY <glacjay@gmail.com>
// @match https://www.youtube.com/playlist?list=*
// @grant none
// ==/UserScript==
@glacjay
glacjay / soft-layers.ahk
Last active January 5, 2022 02:20
simulate multi-layer keyboard
#inputlevel,2
; Esc | LCtrl
$LCtrl::
SetMouseDelay -1
Send {Blind}{LCtrl DownR}
KeyWait, LCtrl
Send {Blind}{LCtrl up}
; MsgBox, %A_ThisHotkey%-%A_TimeSinceThisHotkey%
if (A_ThisHotkey="$LCtrl" and A_TimeSinceThisHotkey < 250)
@glacjay
glacjay / wubi86_single.py
Created January 27, 2021 08:50
制作 rime 五笔86 单字词库
# forked from https://github.com/yekingyan/rime-wubi-86-single/blob/master/wubi86_single.py
import re
INPUT_FILE_PATH = "wubi86.dict.yaml"
OUTPUT_FILE_PATH = "wubi86.dict.yaml.single"
@glacjay
glacjay / IframeDemo.vue
Last active January 7, 2018 09:20
vue 集成 iframe
<template>
<iframe :src="the_url" @load="onIframeLoad" />
</template>
<script>
export default {
data () {
return {
the_url: "http://xxx.com/yyy",
some_id: 42