Skip to content

Instantly share code, notes, and snippets.

View gist:1a35b380bac510ad8795
#!/bin/bash
#
# chkconfig: 23 90 10
# Description: Quickly hacked together bigcouch init script for CentOS systems.
. /etc/init.d/functions
PID_FILE=/var/run/bigcouch.pid
BIGCOUCH_BIN=/opt/bigcouch/bin/bigcouch
SUBSYS_LOCK_FILE=/var/lock/subsys/bigcouch
@mike-zhang
mike-zhang / httpShareWithTrace.go
Created Oct 10, 2012
http Share With Trace (golang)
View httpShareWithTrace.go
/*
File : httpShareWithTrace.go
Author : Mike
E-Mail : Mike_Zhang@live.com
*/
package main
import (
"net/http"
"os"
"strings"
@mike-zhang
mike-zhang / watch_eth0.sh
Created Oct 15, 2012
定时显示特定网卡信息供查看
View watch_eth0.sh
#! /bin/sh
if [ -f '/usr/bin/watch' ]
then
watch -n 1 -d ifconfig eth0
#watch ifconfig eth0
else
#while [ 1 ];do ifconfig eth0 ;sleep 1;clear;done
while [ 1 ]
do
@mike-zhang
mike-zhang / find_if_inMemeberFun.cpp
Created Oct 18, 2012
STL find_if in member function
View find_if_inMemeberFun.cpp
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
using namespace std;
class CMyTest
{
public:
bool IsOdd ( int i)
@mike-zhang
mike-zhang / debugTest.cpp
Created Oct 24, 2012
使用预处理进行调试(c++ demo)
View debugTest.cpp
#include <iostream>
//#define NDEBUG // or : g++ -DNDEBUG debugTest.cpp -o debugTest
#include <cassert>
using namespace std;
int main()
{
cout<<__FILE__<<endl;
cout<<__LINE__<<endl;
@mike-zhang
mike-zhang / ptrSwap.cpp
Created Oct 25, 2012
交换两个指针(c++)
View ptrSwap.cpp
#include <iostream>
using namespace std;
//using pointer
void ptrSwap1(int **pa,int **pb)
{
int *ptmp = *pa;
*pa = *pb;
*pb = ptmp;
@mike-zhang
mike-zhang / wordCount1.cpp
Created Nov 5, 2012
STL map test : word count
View wordCount1.cpp
#include <map>
#include <string>
#include <iostream>
using namespace std;
int main()
{
map<string,int> dict;
string word;
@mike-zhang
mike-zhang / record1.py
Created Nov 8, 2012
抓取linux桌面视频
View record1.py
#! /bin/bash
t1=`date +%Y%m%d%H%M`
path1="/tmp/out_$t1.mpg"
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq $path1
@mike-zhang
mike-zhang / netstatWatch.sh
Created Nov 9, 2012
定时显示与特定主机的连接
View netstatWatch.sh
#! /bin/bash
r_host='10.11.1.100'
if [ -f '/usr/bin/watch' ]
then
watch -n 1 -d "netstat -an | grep $r_host"
else
while [ 1 ]
do
@mike-zhang
mike-zhang / streamIteratorTest.cpp
Created Nov 11, 2012
流迭代器和算法一起使用
View streamIteratorTest.cpp
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
istream_iterator<int> cin_it(cin);