Skip to content

Instantly share code, notes, and snippets.

Avatar
☢️

Yuxiang Zhang z4yx

☢️
View GitHub Profile
@z4yx
z4yx / git-completion.tcsh
Last active Oct 9, 2021 — forked from apbarrero/git-completion.tcsh
Source this file in your .tcshrc to get git command completion. Original source is http://gtirtha.wordpress.com/2010/05/14/git-autocomplete/ but WordPress's WSYIWYG editor messed it up and I cleaned it up.
View git-completion.tcsh
# Source this script in tcsh to setup shell completions
# for git. Completions are activated by typing or Control-D
# in the shell after entering a partial command.
#
# Usage:
# source git-completion.tcsh (e.g. in ~/.cshrc)
#
# Supported completions:
# git (lists git commands)
# git help (lists git commands)
View thu-route.sh
#!/bin/bash
ip -batch - <<EOF
r add 59.66.0.0/16 via 166.111.226.129 table users
r add 101.5.0.0/16 via 166.111.226.129 table users
r add 101.6.0.0/16 via 166.111.226.129 table users
r add 118.229.0.0/20 via 166.111.226.129 table users
r add 166.111.0.0/16 via 166.111.226.129 table users
r add 183.172.0.0/16 via 166.111.226.129 table users
r add 183.173.0.0/17 via 166.111.226.129 table users
@z4yx
z4yx / dmesg.log
Created Apr 2, 2021
kernel log of Ubuntu Linux on Mac mini M1
View dmesg.log
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x611f0221]
[ 0.000000] Linux version 5.11.0-rc4+ (buildserv@corellium.com) (aarch64-linux-gnu-gcc (Linaro GCC 7.4-2019.02) 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4], GNU ld (Linaro_Binutils-2019.02) 2.28.2.20170706) #192 SMP Mon Feb 1 17:40:41 EST 2021
[ 0.000000] Machine model: Mac Mini Late 2020
[ 0.000000] earlycon: apple_uart0 at MMIO 0x0000000235200000 (options '')
[ 0.000000] printk: bootconsole [apple_uart0] enabled
[ 0.000000] [Firmware Bug]: Kernel image misaligned at boot, please fix your bootloader!
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x000000080134c000-0x00000009db5dffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
View wifi-conn-check.sh
#!/bin/bash
while true; do
fails=0
while ! ping -c1 $1 &>/dev/null;do
echo "Ping Fail $fails - `date`"
fails=$(($fails+1))
if [[ $fails > 3 ]]; then
echo "Restarting the Wi-Fi connection"
nmcli c down cqtest
View sfpi-test.py
l = ['B7','B6','E20','B5','B3','B2','C3','C0','C1','E22','G0','G2','G4','G5','G3','G1','E21','C2','B0','B1','B4']
n = []
path = '/sys/class/gpio'
for io in l:
num = ord(io[0])-ord('A')
num = num*32+int(io[1:])
n.append(num)
for num in n:
print('echo %d >%s/export'%(num,path))
print('echo out >%s/gpio%d/direction'%(path,num))
@z4yx
z4yx / wiper.sh
Created May 20, 2020
ketanarlulkar/hdparm
View wiper.sh
#!/bin/bash
#
# SATA SSD free-space TRIM utility, by Mark Lord <mlord@pobox.com>
VERSION=3.6
# Copyright (C) 2009-2010 Mark Lord. All rights reserved.
#
# Contains hfsplus and ntfs code contributed by Heiko Wegeler <heiko.wegeler@googlemail.com>.
# Package sleuthkit version >=3.1.1 is required for HFS+. Package ntfs-3g and ntfsprogs is required for NTFS.
View yubikey-notice.py
import sys
import subprocess
import notify2
import dbus
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop
import yubico
def check(bus, msg):
if msg.get_path() != "/ScreenSaver":
return
View rpi4-headless-init.sh
echo "" >>/media/removable/boot/config.txt
echo "enable_uart=1" >>/media/removable/boot/config.txt
touch /media/removable/boot/ssh
cat >/media/removable/boot/wpa_supplicant.conf <<EOF
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="dd-wrt"
View bpf_helpers.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __BPF_HELPERS_H
#define __BPF_HELPERS_H
/* helper macro to place programs, maps, license in
* different sections in elf_bpf file. Section names
* are interpreted by elf_bpf loader
*/
#define SEC(NAME) __attribute__((section(NAME), used))
View 0127-mtd-spi-nor-add-support-for-winbond-OTP.patch
From 84a933323d59b27ae85cf16deddc254a0b17e450 Mon Sep 17 00:00:00 2001
From: Shraddha Chaudhari <Shraddha.Chaudhari@imgtec.com>
Date: Tue, 5 Jan 2016 11:16:43 +0530
Subject: mtd: spi-nor: add support for winbond OTP
Few winbond spi nor devices support 3 x 256 bytes
of security registers, add support for read, write, lock
of these registers as user OTP.
Also add support for reading winbond devices unique ID