Skip to content

Instantly share code, notes, and snippets.

@cuixin
cuixin / limits.conf
Created September 24, 2014 09:08
resolve Linux "Too many files open" error
#/etc/security/limits.conf
* hard nofile 1024000
* soft nofile 1024000
root hard nofile 1024000
root soft nofile 1024000
@cuixin
cuixin / GenRndLetter.go
Created October 27, 2015 10:45
Using golang easier to generate only letters by random.
package main
import (
"crypto/rand"
"fmt"
"io"
)
func newId(size int) string {
k := make([]byte, size)
@cuixin
cuixin / beanstalkd.sh
Created December 8, 2015 05:31
install beanstalkd on centos
Step 0. Install git
yum install git
Step 1. Clone repository
git clone git://github.com/kr/beanstalkd.git
cd beanstalkd
make
cp beanstalkd /usr/bin/beanstalkd
@cuixin
cuixin / docker-search-with-tags.sh
Created March 4, 2016 09:16
search docker images with tags.
#!/bin/sh
#
# Simple script that will display docker repository tags.
#
# Usage:
# $ docker-show-repo-tags.sh ubuntu centos
for Repo in $* ; do
# curl -s -S "https://registry.hub.docker.com/v2/repositories/library/$Repo/tags/" | \
curl -s S "https://registry.hub.docker.com/v1/repositories/$Repo/tags" | \
sed -e 's/,/,\n/g' -e 's/\[/\[\n/g' | \
@cuixin
cuixin / client.py
Created April 27, 2016 08:37 — forked from redbo/client.py
import pycurl
import cStringIO
c = pycurl.Curl()
c.setopt(pycurl.VERBOSE, 1)
dummydata = "HI THIS IS SOME DATA"
c.setopt(pycurl.URL, "http://127.0.0.1:9000/noreadbody")
@cuixin
cuixin / watch.sh
Created June 17, 2016 02:14 — forked from mikesmullin/watch.sh
watch is a linux bash script to monitor file modification recursively and execute bash commands as changes occur
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <mike@smullindesign.com>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#
@cuixin
cuixin / puddle.go
Created October 10, 2016 10:28
twitter-puddle problem solution in golang.
package main
import "fmt"
func calc(values []int) int {
var (
left = 0
right = len(values) - 1
lmax = values[0]
rmax = values[right]
@cuixin
cuixin / webserver.go
Created October 19, 2016 10:11
simply web file server implemented by golang.
package main
import (
"flag"
"net/http"
)
var port = flag.String("p", ":8080", "port")
var dir = flag.String("d", "web", "directory")
@cuixin
cuixin / excel2csv.go
Created December 1, 2016 02:19
Excel To CSV Files example code.
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"strconv"
"strings"
@cuixin
cuixin / pngkiller.go
Last active December 27, 2016 02:37
Check your all images dimension is equal.
package main
import (
"fmt"
"image"
_ "image/jpeg"
_ "image/png"
"os"
"path/filepath"
"strings"