Skip to content

Instantly share code, notes, and snippets.

@jsfaint
jsfaint / lanconf.exp
Created March 24, 2017 08:04
Control lanconf with expect
#!/usr/bin/env expect
set timeout 6
set send_slow {1 .1}
spawn ./lanconf32 textmode
expect {
"Press any key to continue." {send -s " ";}
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
void sig_handler(int signo)
{
printf("Signal %d", signo);
exit(1);
}
@jsfaint
jsfaint / mac_update.sh
Created March 24, 2017 07:58
Update MAC address using ethtool
#!/bin/bash
PATTERN='^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
print_usage() {
echo "Need NIC name"
echo "usage: $0 eth0 00:11:22:33:44:55"
}
if [ -z $1 ]; then
@jsfaint
jsfaint / auto_sys_inst.sh
Created March 24, 2017 07:47
Build a live usb disk from rootfs.tgz
#!/bin/bash -
###############################################################################
# FILENAME:
# auto_sys_inst.sh
#
# DESCRIPTION:
# Build a live usb disk from rootfs.tgz
#
# REVISION(MM/DD/YYYY):
# 11/22/2011 jia.sui(jia.sui@advantech.com.cn)
@jsfaint
jsfaint / rpm_file.sh
Created March 24, 2017 07:46
Get type and RPM owner of files under a given path.
#!/bin/bash
# -----------------------------------------------
#
# rpm_file.sh
#
# Description: Get type and RPM owner of files under a given path.
#
# usage:
# ./rpm_file.sh [PATH]
# param:
@jsfaint
jsfaint / update_git.sh
Created March 22, 2017 05:09
Update git for CentOS, build from source
#!/bin/bash
[ -z $1 ] && echo "Missging git src path" && exit 1
git_src=$1
cd $git_src
make prefix=/usr
sudo make prefix=/usr install
@jsfaint
jsfaint / month.vim
Created March 22, 2017 02:24
simple vim completefunc just a demo
let s:month = {
\ '1': 'Jan',
\ '2': 'Feb',
\ '3': 'Mar',
\ '4': 'Apr',
\ '5': 'May',
\ '6': 'Jun',
\ '7': 'Jul',
\ '8': 'Aug',
\ '9': 'Sep',
@jsfaint
jsfaint / build_ycm.sh
Created August 24, 2015 05:21
Build youcompleteme for Linux/OS X
#!/bin/bash
os=`uname`
if [[ x$os == x"Darwin" ]]; then
export PATH=/Library/Developer/CommandLineTools/usr/lib:$PATH
fi
cd ./vimfiles/bundle/youcompleteme/
git submodule update --init --recursive
@jsfaint
jsfaint / sdr-clean.sh
Created June 5, 2015 03:08
Kindle Utility: Clean orphan sdr folder which books has been removed
#!/bin/bash
#author: Jia Sui
#email: jsfaint@gmail.com
#Description: Clean orphan sdr folder which books has been removed.
# Check if Kindle was mounted
df -h | grep -i kindle > /dev/null
if [[ $? -ne 0 ]]; then
echo "Kindle was not mounted"
exit 1
@jsfaint
jsfaint / restart_dns.sh
Last active August 29, 2015 14:20
Restart DNS for yosemite(10.10), good new: apple will remove discoveryd, and use the old mDNSresponder in El Capitan(10.10)
#!/usr/bin/env bash
sudo launchctl unload -w com.apple.discoveryd.plist
sudo launchctl load -w com.apple.discoveryd.plist