Skip to content

Instantly share code, notes, and snippets.

@rainly
rainly / setup.sql
Created August 30, 2012 09:17 — forked from imperialwicket/setup.sql
PostgreSQL monthly table partitions
--
-- Setup - Add plpgsql, create a parent table, create an initial child table,
-- create the trigger and the initial trigger function.
--
-- We'll need plpgsql, so create it in your db if it's not already available.
CREATE LANGUAGE plpgsql;
-- Create a table to act as parent with the appropriate columns for your data.
CREATE TABLE my_schema.my_data (name varchar(24), create_date timestamp);
@rainly
rainly / gist:3637224
Created September 5, 2012 14:11 — forked from liweinan/gist:3629763
out

#对non-lock queue的简单分析#

今天看到 @梁斌penny 在打擂:http://coderpk.com

内容如下:

游戏规则: 比赛由pennyliang,就是本人梁斌同志坐庄,我提交baseline代码(可执行程序),和部分代码,方便统一游戏规则。 10亿数据(每个数据看作一个同志),1个队列,10个线程push,10个线程pop,走完一遍,考察总耗时,耗时最短的获胜。我的代码在我自己机器10亿数据排队进出,耗时1分28秒,内存峰值256MB(CPU16核,真8核那种,Intel(R) Xeon(R) CPU E5540 @ 2.53GHz)

@rainly
rainly / gist:3856759
Created October 9, 2012 05:17 — forked from dnagir/gist:1573414
Run Postgres Specs in Ramdisk
  • This creates a 560mb ramdisk. Adjust the size accordingly. I think the number at the end of the command is the number of disk blocks. They are 2kb in size for me.
  • Restarting postgres is not necessary; you can create the ramdisk and tablespace while postgres is running.
  • You will lose all data in the ramdisk tablespace when you shut your machine down

  $ diskutil erasevolume HFS+ "postgres_ramdisk" `hdiutil attach -nomount ram://1165430`
  Started erase on disk1
  Unmounting disk
  Erasing
 Initialized /dev/rdisk1 as a 569 MB HFS Plus volume
@rainly
rainly / gist:3883133
Created October 13, 2012 03:36
Youdao for Shell
#########################################
RED_ORG="\033[0;31m"
GREEN_ORG="\033[0;32m"
NO_COLOR_ORG="\033[0m"
# youdao helpers
function t {
if [ $1 == "-a" ]; then
all=1
query=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$2" "" | sed -e "s/\/\?//g")
@rainly
rainly / .tmux.conf
Created October 26, 2012 03:23 — forked from terrywang/.tmux.conf
Terry's tmux conf
# Terry's ~/.tmux conf file
# Based on tmux book written by Brian P. Hogan
# c-a o to switch to another panel
# c-d to close shell
# c-a ! to close panel
# c-a w to list windows
# c-a " split pane horizontally
# c-a % split pane vertically
# Setting the prefix from C-b to C-a
openssl s_client -connect github.com:443 -showcerts 2>&1 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed -ne '1,/-END CERTIFICATE-/p' > /tmp/github.com.pem
openssl x509 -in /tmp/github.com.pem -sha1 -noout -fingerprint
#!/bin/bash
#
# Install Postgres 9.2 on a clean Ubuntu 12.04
"""
LC_ALL issue
comment out the AcceptEnv LANG LC_* line in the remote /etc/ssh/sshd_config file.
sudo apt-get install language-pack-en-base
sudo dpkg-reconfigure locales
comment out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file.
RH & CentOS
1. mv /etc/modprobe.d/ipv6.conf /var/tmp
2. cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 mode=0 miimon=100 downdelay=200 updelay=200
rh 6.0 kickstart with gpt.
1. add necessary service, remove unnecessary service
2. The last section starting with "#$SNIPPET('custom/xxyy')" are some post install scripts:
* modify /etc/hosts
127.0.0.1 localhost.localdomain localhost
private_ip hostname.jaseywang.me hostname
* remove zero route
* add some parameters to kernel options
* disable ipv6
* add ntp server for each server to sync time
Boa noite pessoal , segue abaixo um script de hardening para servidores redhat , logico que voce pode adaptar para distro de seu servidor , fique a vontade para modificar e alterar o mesmo ,queria agradecer tambem ao meu camarada from hell @alexandrosilva e @crashbrz ambos do dclabs www.dclabs.com.br segue abaixo.
#! /bin/bash
#
# _ _ _
# | | | | _ (_)
# ____| | _____ ____ __| |_____ ___ _| |_ _ ____ _____