Skip to content

Instantly share code, notes, and snippets.

View goodjob1114's full-sized avatar

Randy Chen goodjob1114

View GitHub Profile
@goodjob1114
goodjob1114 / handleCSV.rb
Created November 27, 2015 09:01
read csv and write to file (append)
IO.foreach("./test.csv") do |line|
# Remove trailing whitespace.
line.chomp!
# Split on comma.
values = line.split(",")
# Write results.
IO.write("/tmp/testfile", values.join("+") << "... " << String(values.length) << "\n", mode: 'a')
@goodjob1114
goodjob1114 / ropencc-install-memo.md
Last active December 17, 2015 07:43
opencc and ropencc install memo

ubuntu 14.04

install opencc latest version

sudo apt-get install Doxygen
cd /tmp
git clone git@github.com:BYVoid/OpenCC.git
cd OpenCC
make
sudo make install
@goodjob1114
goodjob1114 / gem-pg.md
Created December 24, 2015 03:34
deal with [An error occurred while installing pg (0.18.4), and Bundler cannot continue.] on ubuntu 14.04
sudo apt-get install libpq-dev
gem install pg -v '0.18.4'
# add gem 'pg' to Gemfile
bundle install
@goodjob1114
goodjob1114 / partial-md5.sh
Last active December 29, 2015 16:29
partial md5sum
#!/bin/bash
help_info() {
echo "Usage : $0 file"; exit 0
}
if [ $# -lt 1 ]; then
help_info
else
if [ -f "$1" ]; then
@goodjob1114
goodjob1114 / ansible-gce.sh
Created January 12, 2016 07:52 — forked from samklr/ansible-gce.sh
Ansible GCE setup
#! /bin/sh
### Must have Gcloud sdk installed and configured
###Create a micro instance as ansible master
gcloud compute --project $PROJECT_NAME instances create "ansible" --zone "us-central1-b" --machine-type "f1-micro" --network "default" --maintenance-policy "MIGRATE" --scopes "https://www.googleapis.com/auth/userinfo.email" "https://www.googleapis.com/auth/compute" "https://www.googleapis.com/auth/devstorage.full_control" --tags "http-server" "https-server" --no-boot-disk-auto-delete
###or a centos like in the tutorial
gcloud compute --project $PROJECT_NAME instances create "ansible-master" --zone "us-central1-b" --machine-type "g1-small" --network "default" --maintenance-policy "MIGRATE" --scopes "https://www.googleapis.com/auth/userinfo.email" "https://www.googleapis.com/auth/compute" "https://www.googleapis.com/auth/devstorage.full_control" --tags "http-server" "https-server" --image "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-7-v20140926" --no-boot-disk-auto-de
# Disque configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@goodjob1114
goodjob1114 / golang-vscode-devtool.md
Last active January 22, 2016 14:30
golang vscode devtool .... on linux & MacOS for Gophers
@goodjob1114
goodjob1114 / http_get.go
Created January 21, 2016 09:40 — forked from ijt/http_get.go
Example of using http.Get in go (golang)
package main
import (
"fmt"
"http"
"io/ioutil"
"os"
)
func main() {
@goodjob1114
goodjob1114 / install-golang-by-gvm.sh
Last active January 28, 2016 08:58
install-golang-by-gvm
#!/bin/bash
case ${OSTYPE} in
linux-gnu)
r=$(lsb_release -si)
if [ $r == "Ubuntu" ] || [ $r == "Debian" ]; then
sudo apt-get install -y binutils bison gcc make git
else
echo "Not Ubuntu..."
fi
@goodjob1114
goodjob1114 / client.go
Created February 1, 2016 07:33 — forked from spikebike/client.go
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)