Skip to content

Instantly share code, notes, and snippets.

View goodjob1114's full-sized avatar

Randy Chen goodjob1114

View GitHub Profile
@goodjob1114
goodjob1114 / crypto-aes-practice.js
Created May 14, 2015 09:29
encrypt data using crypto::aes-256-cbc on Node.js
var crypto = require('crypto')
var cipher = function(key, plaintext){
console.log('cipher::init')
var cipher = crypto.createCipher('aes-256-cbc', key)
var encriptedText = cipher.update(plaintext, 'utf8', 'hex')
@goodjob1114
goodjob1114 / hhvm-nginx-mariadb-installMemoOnUbuntu14.04.md
Last active July 5, 2019 16:27
hhvm, nginx, php, mariadb -> [laravel] install memo used on Ubuntu 14.04

ubuntu 14.04

sysv-rc-conf (service control tool)

sudo apt-get install -y sysv-rc-conf

nginx

sudo add-apt-repository -y ppa:nginx/stable 
@goodjob1114
goodjob1114 / bcrypt-moment-secret.js
Last active August 29, 2015 14:22
generate some secret hash based on Moment and Bcrypt.....just for fun
var co = require('co')
var bcrypt = require('bcrypt')
var moment = require('moment')
var Promise = require('bluebird')
var bSalt = Promise.promisify(bcrypt.genSalt)
var bHash = Promise.promisify(bcrypt.hash)
var passphrase = moment().format('YYYY[RandomString]MMDDHH')
console.log('passphrase =',passphrase)
@goodjob1114
goodjob1114 / genSSL.sh
Created June 24, 2015 17:52
simple ssl generate shell script
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
SSL_FOLDER="../ssl"
if [ -d "$SSL_FOLDER" ]; then
echo "ssl folder existed"
@goodjob1114
goodjob1114 / freeBootDiskSpace.sh
Created June 29, 2015 03:03
[ubuntu] free boot disk space
#!/bin/bash
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
@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);
@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 / 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 / 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 / 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