Skip to content

Instantly share code, notes, and snippets.

View goodjob1114's full-sized avatar

Randy Chen goodjob1114

View GitHub Profile
@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
@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 / 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 / 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 / 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 / add_milliseconds_to_mysql_and_activerecord_timestamps.md
Created November 6, 2015 08:01 — forked from iamatypeofwalrus/add_milliseconds_to_mysql_and_activerecord_timestamps.md
ActiveRecord: Store Milliseconds (or Microseconds) in Timestamps/Datetimes with Rails / MySQL

ActiveRecord: Store Milliseconds (or Microseconds) in Timestamps with Rails / MySQL

Milliseconds in your Timestamps.

We got 'em, you want 'em.

Why

Shit needs to be PRECISE

LICENSE

MIT

@goodjob1114
goodjob1114 / gvm-go1.5.sh
Created October 29, 2015 02:45
error with gvm install go1.5... @dariusc93's solution
#!/bin/bash
# https://github.com/moovweb/gvm/issues/155
gvm install go1.4
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.5
@goodjob1114
goodjob1114 / cloud-config.example.yaml
Last active May 4, 2022 13:10
cloud-config.yaml example for install coreos to disk....$ coreos-install -d /dev/sda -C stable -c cloud-config.yaml
#cloud-config
hostname: yourcorename
coreos:
etcd:
addr: $public_ipv4:4001
peer-addr: $private_ipv4:7001
units:
- name: etcd.service
@goodjob1114
goodjob1114 / howToModifyOvaFile.md
Last active January 27, 2024 10:49
how to modify .ova file on linux/Mac using terminal....export vm (OVF 1.0) from virtualbox, then modify some tag and hash value for import vm to ESXi

extract ova files from an archive

$ tar -xvf vmName.ova

modify ovf for some invalid tag

$ vi vmName.ovf
@goodjob1114
goodjob1114 / sf-test.js
Created August 19, 2015 08:41
split file test
// npm install --save split-file
// https://github.com/tomvlk/node-split-file
var sf = require('split-file');
sf.splitFile('unicorn.png', 10, function(err, names) {
if(err) return console.log(err);
console.log(names);
sf.mergeFiles(names, 'unicorn.merge.png', function(err, outputFile) {
if(err) return console.log(err);