Skip to content

Instantly share code, notes, and snippets.

@WeponX
WeponX / removeswap
Created June 30, 2017 02:34
remove swapfile
#!/bin/sh
# does the swap file exist?
grep -q "swapfile" /etc/fstab
# if it does then remove it
if [ $? -eq 0 ]; then
echo 'swapfile found. Removing swapfile.'
sed -i '/swapfile/d' /etc/fstab
echo "3" > /proc/sys/vm/drop_caches
swapoff -a
rm -f /swapfile
@WeponX
WeponX / createswap.sh
Created June 30, 2017 02:33
Create swap file
#!/bin/sh
# size of swapfile in megabytes
swapsize=1024
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
echo 'swapfile not found. Adding swapfile.'
fallocate -l ${swapsize}M /swapfile
chmod 600 /swapfile
@WeponX
WeponX / tmux.conf.local
Last active February 24, 2017 11:28
the local tmux config file for the repo
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind v split-window -h
bind s split-window -v
unbind '"'
unbind %
@WeponX
WeponX / .screenrc
Last active February 23, 2017 02:04
Screen config file
startup_message off
escape ^Zz
defscrollback 1024
hardstatus on
hardstatus alwayslastline
backtick 101 30 30 sh -c 'screen -ls | grep --color=no -o "$PPID[^[:space:]]*"'
hardstatus string '%{= Kd} %{= Kd}%-w%{= Kr}[%{= KW}%n %t%{= Kr}]%{= Kd}%+w %-= %{KG} %H%{KW}|%{KY}%101`%{KW}|%D %M %d %Y%{= Kc} %C%A%{-}'
term xterm-256color
vbell off
bind w windowlist -b
@WeponX
WeponX / README.md
Created February 14, 2017 08:40 — forked from nicerobot/README.md
Mac OS X uninstall script for packaged install of node.js

To run this, you can try:

curl -ks https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh | bash

I haven't tested this script doing it this way but i run a lot of my Gists like this so maybe this one'll work too.

Alternatively,

curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh

chmod +x ./uninstall-node.sh

@WeponX
WeponX / iscsi_lun.sh
Last active November 3, 2016 12:28
Create Iscsi LUN
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage:iscsi_lun lun_number";
exit
fi
pkg install target
svcadm enable -r svc:/network/iscsi/target:default
itadm create-target
@WeponX
WeponX / QuickChangeDir
Last active March 8, 2017 02:39
Ubuntu dir change script
export MARKPATH=$HOME/.marks
export MARKDEFAULT=gavin#设置你的默认书签,可以直接输入g跳转
function g {
local m=$1
if [ "$m" = "" ]; then m=$MARKDEFAULT; fi
cd -P "$MARKPATH/$m" 2>/dev/null || echo "No such mark: $m"
}
function mark {
mkdir -p "$MARKPATH"
@WeponX
WeponX / ssh-login
Last active February 14, 2017 08:07
Auto SSH remote login script
#!/usr/bin/expect
# 设置超时时间为 60 秒
set timeout 60
# 设置要登录的主机 IP 地址
set host hostname
# 设置以什么名字的用户登录
set name user
# 设置用户名的登录密码
set password passwd
@WeponX
WeponX / initator.sh
Last active November 10, 2016 09:53
Mpapi Initator
#!/bin/bash
arch = ""
if [ `uname -i` = "i86pc" ];then
arch="i386"
else
arch="sparc"
fi
echo "Arch: $arch"
pkg install service/network/legacy-remote-utilities