Skip to content

Instantly share code, notes, and snippets.

@zeroxia
zeroxia / nmap-scan.sh
Created March 19, 2014 08:18
nmap command to scan the network
#!/bin/sh
#IFACE=eth1
# # LAN host discovery
# seq 0 255 | while read subnet; do
# echo subnet: 192.168.$subnet.0
# ##sudo ifconfig $IFACE 192.168.$subnet.100
# ##sudo nmap -n -sP -PA 192.168.$subnet.-99,101-
# done
@zeroxia
zeroxia / run-dl.sh
Created March 8, 2015 08:28
xunlei-lixian batch invocation shell script
#!/bin/sh
LOG_FILE=./log.txt
if [ -z "$1" ]; then
echo "Usage: $0 LIST [LOG]"
exit 0
fi
if [ -n "$2" ]; then
@zeroxia
zeroxia / modtracker.sh
Created May 7, 2015 12:13
Modify tracker URL of transmission tasks.
#!/bin/sh
## TODO: Fill the following placeholders:
## USERNAME, PASSWORD
## YOUR_PASSKEY
trr() {
transmission-remote 127.0.0.1:9091 -n USERNAME:PASSWORD "$@"
}
@zeroxia
zeroxia / install-rar-as-alternatives.sh
Created May 7, 2015 13:11
To install various links for rarlinux commands and related files.
#!/bin/sh
update-alternatives --install /usr/local/bin/rar rar /opt/rar/rar_static 50 \
--slave /etc/rarreg.key rarreg.key /opt/rar/rarreg.key \
--slave /etc/rarfiles.lst rarfiles.lst /opt/rar/rarfiles.lst \
--slave /usr/local/lib/default.sfx default.sfx /opt/rar/default.sfx \
--slave /usr/local/share/man/man1/rar.1.gz rar.1.gz /opt/rar/rar.1.gz \
--slave /usr/local/bin/unrar unrar /opt/rar/unrar \
--slave /usr/local/share/man/man1/unrar.1.gz unrar.1.gz /opt/rar/unrar.1.gz
@zeroxia
zeroxia / etc_init.d_rcS
Created May 12, 2015 13:02
rcS file and my tweaking files for PogoPlug Series 4 box. The "rcS2" scripts aim to start the Samba service installed as optware on the mmcblkp0 device (the SD card slot).
#-*- 1. /etc/init.d/rcS changes -*-
#! /bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
mount -t tmpfs none /tmp
mkdir /tmp/var
@zeroxia
zeroxia / outlook_2013_dismiss_due_reminders.vbs
Created June 25, 2015 12:54
Dismiss annoying Outlook 2013 due reminders, but still buggy, who can improve it? Thanks!
' Declare this Wbject withEvents displaying all the events
Private WithEvents olRemind As Outlook.Reminders
Private Sub Application_Startup()
' Set olRemind = Outlook.Reminders
' KillOverdueReminders
End Sub
Private Sub KillOverdueReminders(Cancel As Boolean)
' Purpose: Kills all reminders for past due appointments.'
@zeroxia
zeroxia / pic16_io2uart.c
Created July 3, 2015 05:16
Using GPIO pin to emulate "TX" function of UART communication (TTL levels)
#include <xc.h>
/* Microcontroller MIPs (FCY) */
#define SYS_FREQ 4000000L
#define _XTAL_FREQ SYS_FREQ
/* #define FCY SYS_FREQ/4 */
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
@zeroxia
zeroxia / PAGEANT.bat
Last active December 27, 2015 05:39
To enable ssh hop with key forwarding, doing the following two things is not enough: 1. PuTTY session configuration, enable "Allow agent forwarding" under "Connection --> SSH -> Auth"; 2. Start the PAGEANT.exe utility program. There is a third important step: Load your private key (.ppk format by PuTTY) into the PAGEANT agent manager. The follow…
@ECHO OFF
if not "%~1" == "" (
set PPK_FILE=%~1
) else (
set PPK_FILE=kanna.ppk
)
if not exist %PPK_FILE% (
REM Assume the PPK file is located aloneside PAGEANT.exe
@zeroxia
zeroxia / gcc_predefined_macros.sh
Created November 25, 2013 06:11
Show what macros are predefined by your GCC. e.g., for Android, you can rely on -D__ANDROID__
#!/bin/sh
echo "Hello, world"
# PC linux
echo | gcc -dM -E - | less
# For the Android NDK toolchains
echo | /opt/android/android-ndk/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-linux-android-gcc -dM -E -
@zeroxia
zeroxia / find_equal_len.py
Last active May 12, 2016 12:57
Find lines with equal "left" and "right" parts that are separated by the Chinese comma ","
#!/usr/bin/python3
# vim: set ts=4 et:
import re
p = re.compile("^(.*),(.*)。$")
with open("input.txt") as f:
for lno, line in enumerate(f):
mo = p.match(line.rstrip())