Skip to content

Instantly share code, notes, and snippets.

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.2-2smp i686) [Netscape]">
</head>
<body>
&nbsp;
<table BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#000000" NOSAVE >
<tr NOSAVE>
@m13253
m13253 / anti-xp-2.php
Last active August 29, 2015 13:56 — forked from xfoxfu/anti-xp-2.php
<?php
/**
* Anti-XP Script
*
* @author 小傅Fox[<xfox@cotr.me>]
*/
/**
* 获得客户端的操作系统
* Source:{@link http://lok.me/a/1027.html}
*
@m13253
m13253 / gist:9546968
Last active August 29, 2015 13:57
My package selection for an initial ArchLinux installation
pacman -S -y --root /mnt --config /mnt/etc/pacman.conf.pacsave --cachedir /mnt/var/cache/pacman/pkg base base-devel bash-completion vim grub wireless_tools net-tools inetutils dnsutils btrfs-progs ntfsprogs ntfs-3g arch-install-scripts gnome gdm xorg-drivers networkmanager networkmanager-dispatcher-ntpd networkmanager-dispatcher-sshd networkmanager-openconnect networkmanager-openvpn networkmanager-pptp networkmanager-vpnc rp-pppoe
@m13253
m13253 / sysctl.conf
Last active August 29, 2015 13:59
TCP tuning for high latency network in sysctl.conf -- http://hong.im/2013/04/20/linux-tcp-tuning/
# http://hong.im/2013/04/20/linux-tcp-tuning/
net.ipv4.tcp_syncookies = 1
# 表示开启 SYN Cookies。当出现 SYN 等待队列溢出时,启用 cookies 来处理,可防范少量 SYN 攻击,默认为 0,表示关闭;
net.ipv4.tcp_tw_reuse = 1
# 表示开启重用。允许将 TIME-WAIT sockets 重新用于新的 TCP 连接,默认为 0,表示关闭;
net.ipv4.tcp_tw_recycle = 1
# 表示开启 TCP 连接中 TIME-WAIT sockets 的快速回收,默认为 0,表示关闭;
net.ipv4.tcp_fin_timeout = 15
# 修改系統默认的 TIMEOUT 时间。
@m13253
m13253 / retry.sh
Created May 24, 2014 15:53
A shell script to keep trying a command until it succeeds
#!/bin/bash
_RETRY_COUNT=0
while true
do
("$@") && break
let _RETRY_COUNT=${_RETRY_COUNT}+1
echo -e "\e[1;31mRetry ${_RETRY_COUNT}...\e[0m"
sleep 0.5; echo -ne '\a'; sleep 0.5; echo -ne '\a'; sleep 0.5; echo -ne '\a'; sleep 0.5
done
@m13253
m13253 / gensslcert.sh
Last active August 29, 2015 14:04
Generate a self-signed SSL certificate for web server
#!/bin/bash
set -e
outpemfile="${1:-cert.pem}"
tmpprefix="/tmp/gensslcert-$$"
openssl genrsa -des3 -out "$tmpprefix.key" 2048
openssl req -new -key "$tmpprefix.key" -out "$tmpprefix.csr"
openssl rsa -in "$tmpprefix.key" -out "$outpemfile"
rm -f "$tmpprefix.key"
openssl x509 -req -days 365 -in "$tmpprefix.csr" -signkey "$outpemfile" -out "$tmpprefix.crt"
# Geordi memory dumper
geordi: {size_t s=0x400000;printf("0x%08zx: ",s);for(size_t p=s;p<s+64;p++){unsigned char c=*(const unsigned char *)p;printf((c>31&&c<127)?"%c":"\\x%02x",c);}}
@m13253
m13253 / kbgrid_horz.svg
Last active August 29, 2015 14:06
Image representing MIDI keyboard
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@m13253
m13253 / usbreset.c
Created November 2, 2014 16:26
Send a USB port reset to a USB device -- http://askubuntu.com/a/661/299378
/* usbreset -- send a USB port reset to a USB device */
/* http://askubuntu.com/a/661/299378 */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
@m13253
m13253 / dumpargv.py
Created December 30, 2014 14:03
A script which dumps the command line passed to it
#!/usr/bin/env python
'''Dump the command line passed to it'''
import sys
def quote_argv(argv):
for i in argv:
apos = ' ' in i or '\\' in i