Skip to content

Instantly share code, notes, and snippets.

@yamingd
yamingd / my.cnf
Created May 31, 2012 12:52
mysql config collection from internet
################################################################################
## Kontrollkit
## NAME: mt-my.cnf_2GB
## DATE: 2008-10-01
## AUTHOR: Matt Reid
## WEBSITE: http://kontrollsoft.com
## EMAIL: themattreid@gmail.com
## LICENSE: BSD http://www.opensource.org/licenses/bsd-license.php
################################################################################
# WHAT THIS IS
@yamingd
yamingd / gist:3040103
Created July 3, 2012 14:33
Starting Multiple OpenOffice Instances
#!/bin/sh
OOO_HOME=/Applications/OpenOffice.org.app/Contents
OOO_HOST=
OOO_PORT="2002 2003 2004 2005"
USER_HOME=/tmp
_create_home() {
port=$1
home=${USER_HOME}/user/port${port}
mkdir -p ${home}
@yamingd
yamingd / gist:3040119
Created July 3, 2012 14:36
Openoffice server init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: oooserver
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Initscript to start OOo as server
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@yamingd
yamingd / gist:3508181
Created August 29, 2012 07:52
How Pinterest Generate Global Uuid?
class PinId(object):
SHARD_LEN = 46
OBJECT_LEN = 10
@classmethod
def uuid(clz, shard_id, object_type, local_id):
sid = shard_id << clz.SHARD_LEN | object_type << clz.OBJECT_LEN | local_id
return sid
@classmethod
https://klaver.it/linux/sysctl.conf
# Kernel sysctl configuration file for Linux
#
# Version 1.9 - 2011-03-23
# Michiel Klaver - IT Professional
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
@yamingd
yamingd / gist:3740857
Created September 18, 2012 02:05
use ssh and tar to copy files with two pc
tar cf – files | ssh user@192.168.1.18 “tar -C /home/jiaojy -xf -”
files为文件,或者目录
-C 后面指定要拷贝的地址,
user为192.168.1.18上的用户
@yamingd
yamingd / gist:6505352
Created September 10, 2013 05:34
html hight lighter for words, sentences
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
keeps = ('em', 'i', 'b', 'strong', 'p', 'br', 'img', 'u')
CLEANBODY_RE = re.compile(r'<(/?)(.+?)>', re.M)
IMG_SRC = re.compile(r'(src="(.*?)")', re.M)
WORD_RE = re.compile(r'(([\s</]*?)(\w+)([\s>]*?))', re.M)
@yamingd
yamingd / gist:6506417
Created September 10, 2013 08:12
nginx data size
awk 'BEGIN{SUM=0}{if($9="200"){SUM+=$10}}END{print SUM}' 1123.log
awk 'BEGIN{SUM=0}{if($7 ~ /\.3gp/){SUM+=$10}}END{print SUM}' 1123.log
import sys
import time
import multiprocessing
from merge_sort import *
from sort_helpers import *
def split(arr, n):
part_len = len(arr) / n
if part_len == 0:
@yamingd
yamingd / gist:6547452
Created September 13, 2013 06:56
split big file on first column's value
function splitBigFile()
{
tail -n 1000000000 $1 | awk '{
subNum=substr($1,length($1)-1)
print subNum,$0
}' | while read subNum others
do
echo $others >> $2.$subNum
done
}