Skip to content

Instantly share code, notes, and snippets.

View coldfire-x's full-sized avatar

coldfire.x coldfire-x

  • Beijing
View GitHub Profile
@coldfire-x
coldfire-x / weather.py
Created October 18, 2012 15:28
get weather info for chaoyao district Beijing, CN
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import httplib2
# Chaoyang district, Beijing, CN
chaoyang = 101010300
@coldfire-x
coldfire-x / open_tabs.sh
Created October 23, 2012 07:20
open linux multiple terminator tabs under one window
#!/bin/sh
DB1BUGS="mysql xxx"
DB1HW="mysql xxx"
LiveBUGS="mysql xxx"
LiveHW="mysql xxx"
LocalBUGS="mysql xxx"
LocalHW="mysql xxx"
CMD="gnome-terminal --maximize"
@coldfire-x
coldfire-x / ppp0
Created November 2, 2012 07:37
i'm using vpn intensely, but when i'm in office, i still need the connection to my local network, so here is the solution
#!/bin/sh
# put this in /etc/ppp/ppp0
# mac user only
gw=`netstat -nr|grep UGScI|awk '{print $2}'`
# replace 192.168 with your local network
/sbin/route add -net 192.168 -gateway $gw
@coldfire-x
coldfire-x / cpu_affinity.sh
Created November 23, 2012 07:20
get currently cpu affinity from localhost
#!/bin/bash
vmlist=$(virsh list | awk 'NR>2 {print $2}')
for vm in $vmlist
do
#echo "$vm"
virsh vcpuinfo $vm | grep 'CPU A' | awk '{print $3}'
done
@coldfire-x
coldfire-x / vimrc
Last active October 13, 2015 03:58
my vimrc settings
set ruler
set showcmd
set tabstop=4
set expandtab
set softtabstop=4
set shiftwidth=4
set nu
set hlsearch
set incsearch
set foldmethod=marker
@coldfire-x
coldfire-x / rotate.sh
Created November 30, 2012 05:57
nginx rotate log, remove archive logs older than 2 weeks
#!/bin/bash
ARVDATE=`date +%Y%m%d%H%M`
PID=/usr/local/nginx/nginx.pid
cd /usr/local/nginx/logs
for log in sdf.access.log error.log
do
file=lastweek/arv$log$ARVDATE.log
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@coldfire-x
coldfire-x / getPrice.go
Last active December 12, 2015 02:49
get my stock price
package main
import (
"fmt"
"time"
"net/http"
"encoding/json"
"io/ioutil"
)
@coldfire-x
coldfire-x / create_kvm_guest.sh
Created April 22, 2013 03:51
script for creating kvm virtual machine from a raw partition which has DDed the vm image.
#!/bin/sh
USAGE='Usage: ./create_kvm.sh kvm_name lvm hd1'
# kvm_name is the virtual machine's name
# lvm is the virtual machine's image disk path
# hd1 is the addtional disk we want to attach to this kvm
if [ "$1" = "help" ]
then
echo $USAGE
@coldfire-x
coldfire-x / get_ip_percentage.pl
Created June 6, 2013 10:20
get ip percentage from nginx log
#!/usr/bin/perl
use NetAddr::IP;
unless (@ARGV) {
print "usage: $0 file1 file2 file3\n";
exit;
}