Skip to content

Instantly share code, notes, and snippets.

@zjhsdtc
zjhsdtc / sendMail.go
Last active August 29, 2015 14:19 — forked from andelf/sendMail.go
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"
@zjhsdtc
zjhsdtc / main.go
Last active August 29, 2015 14:19 — forked from nmerouze/main.go
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"
@zjhsdtc
zjhsdtc / reflect.go
Created April 17, 2015 07:35
a reflect example of go
package main
import (
"fmt"
"reflect"
)
type boy struct {
Name string
age int
@zjhsdtc
zjhsdtc / makeswap.sh
Created February 10, 2015 05:41
make 2G swap with 1G aliyun ecs ubuntu 12.04LTS
sudo install -o root -g root -m 0600 /dev/null /swapfile
dd if=/dev/zero of=/swapfile bs=1k count=2048k
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
sudo sysctl -w vm.swappiness=10
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
@zjhsdtc
zjhsdtc / service.go
Last active June 29, 2017 06:55
a restful service use go and redis
package main
import (
"flag"
"fmt"
"log"
"net/http"
"runtime"
"time"
ps -ef | grep tomcat | awk '{print $2}' | xargs kill -9
# a little chat room use eventmachine
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
class String
def bold
"\033[1m#{self}\033[0m"
end
iTerm2 emacs 24.2.1 -nw with paredit on OS X 10.8 Norwegian layout
Left Command is my Meta.
Left Alt used for inputting special characters.
Caps Lock is mapped to Control.
 > System Preferences > Keyboard > Keyboard > Special: Caps Lock: ^ Control
iTerm > Preferences > Keys: Left Command key mapped to Right Option
iTerm > Preferences > Profiles > Keys: Right option acts as: +Esc
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import re
ntfs_pattern = re.compile(r'File System Personality: NTFS')
ntfs_device_node = re.compile(r'.*Device Node:.*')
device_dict = {}