Skip to content

Instantly share code, notes, and snippets.

View hwdsl2's full-sized avatar

Lin Song hwdsl2

View GitHub Profile
@pdeschen
pdeschen / wordpress-blog.conf
Created January 17, 2011 20:38
nginx config for wordpress proxying
upstream wordpress {
server 127.0.0.1:80 weight=1 fail_timeout=120s;
}
server {
listen 81;
server_name blog.foo.bar;
proxy_cache_valid 200 20m;
access_log /var/log/httpd/nginx-access.log combined;
@utaani
utaani / seteth1.sh
Created March 22, 2012 23:14
ifconfig eth1 with fixed IP address on Amazon-VPC ENI(Elastic Network Interface)
#!/bin/sh
# set IP address with Amazon-VPC ENI(Elastic Network Interface) address and other.
# get eth0/1 MAC addresses
MACADDR0=`cat /sys/class/net/eth0/address`
MACADDR1=`cat /sys/class/net/eth1/address`
# get eth0/1 IP addresses on ENI
IPADDR0=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MACADDR0}/local-ipv4s/`;
IPADDR1=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MACADDR1}/local-ipv4s/`;
# ifconfig on eth1 (ENI)
/sbin/ifconfig eth1 inet ${IPADDR1} netmask 255.255.255.0 2>&1 >> /tmp/seteth1.log
@mgarratt
mgarratt / example.com.conf
Created October 18, 2013 22:01
Ghost Blog
upstream ghost_upstream {
server 127.0.0.1:2368;
keepalive 64;
}
server {
listen 80;
server_name example.com www.example.com;
@leenasn
leenasn / offset_id_fields_mysql.sql
Created March 18, 2011 09:03
An SQL script to offset the id fields across all tables in a DB.
/*
This script is for updating the auto_increment field by an offset. The logic applied is
max(AUTO_INCREMENT) + current value in the table.
*/
SET @db:='id_new';
select @max_id:=max(AUTO_INCREMENT) from information_schema.tables;
select concat('update ',table_name,' set ', column_name,' = ',column_name,'+',@max_id,' ; ') from information_schema.columns where table_schema=@db and column_name like '%id' into outfile 'update_ids.sql';
@4ft35t
4ft35t / modsecurity.md
Last active March 8, 2016 07:43
ubuntu install modsecurity with nginx

fix APXS error

configure: error: couldn’t find APXS
apache2-prefork-dev

ref1 ref2

BLOCKS=$(nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8 | awk -F "spf1 " '{print $2}' | sed -e "s/include:/\n/g" | sed -e "s/?all\"//g" | grep -v ^$)
echo "$BLOCKS" | while read block; do nslookup -q=TXT $block 8.8.8.8 | awk -F "spf1 " '{print $2}' | sed -e "s/ip4:/\n/g" | sed -e "s/?all\"//g" |grep -v "^ip6:" | grep -v ^$; done ;
@darron
darron / gist:811cf41a6ec3dbfcb97a
Created January 5, 2015 23:19
Get IP Ranges from EC2
#!/bin/bash
# You need: curl, jq, and ipcalc to run this.
# You should already have cut, sort and uniq if you're on OS X or Linux.
RANGES=$(curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq .prefixes | jq '.[] | select(.region=="us-east-1")' | jq 'select(.service=="EC2")' | jq .ip_prefix | cut -d '"' -f 2 | sort | uniq)
for range in $RANGES
do
MIN=$(ipcalc -bn $range | grep "HostMin" | cut -d ':' -f 2)
@yorkxin
yorkxin / README.md
Last active October 27, 2020 12:17
Amazon S3 Redirect Rules Generator

Amazon S3 Redirect Rules Generator

A Ruby script to generate simple Amazon S3 Redirection Rules XML file.

Update: There is an app for that now! Use Amazon S3 Redirector (Web app) and you can generate the XML without any knowledge about Ruby. Thanks to @rainforestapp. BTW, It's open source too.

Dependencies

  • Nokogiri
@sturadnidge
sturadnidge / tmux-1.8-on-CentOS-6.x.txt
Last active May 10, 2021 18:31
Install tmux 1.8 on CentOS 6.x minimal (64bit)
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@santisaez
santisaez / gist:3187798
Created July 27, 2012 12:57
State of the Art: STUN + TURN servers on Linux (July 2012)

STUN implementations

  • stund
  • Content: server daemon and test client for STUN, RFC-3489 only
  • URL does not load, the project seems abandoned
  • The code is also available on SourceForge, last update was on January 2012
  • TCP and TLS modes not supported
  • The server needs two IPs, it’s mandatory and can not be configured
  • C++, no extra libraries required, Windows port available
  • Version = 0.97 (0.96 package available on Debian, 5 years without updates)