Skip to content

Instantly share code, notes, and snippets.

View goodjob1114's full-sized avatar

Randy Chen goodjob1114

View GitHub Profile
@pyk
pyk / output.md
Last active September 7, 2015 09:34
solution of exercise http://tour.golang.org/#38

image

@flisky
flisky / goroutine by example
Created November 5, 2013 03:25
Goroutine By Example
Goroutine By Example
====================
尹吉峰 2013/11/05
Python Thread
-------------
```python
import time
import threading
@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
@devongovett
devongovett / translate.js
Created February 2, 2014 23:14
Use PhantomJS to translate stdin to english using Google Translate. Useful as a textmate command or just a command line tool.
#!/usr/bin/env phantomjs
var system = require('system');
var text = encodeURIComponent(system.stdin.read());
var url = "http://translate.google.com/#auto/en/" + text;
var page = require('webpage').create();
page.settings.userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0';
page.onConsoleMessage = function (msg) {
@DingWeizhe
DingWeizhe / 寶寶.js
Last active March 8, 2017 14:05
新增line的功能
var fs = require('fs'),
http = require('http'),
https = require('https'),
express = require('express'),
bodyParser = require('body-parser'),
request = require('request'),
crypto = require('crypto'),
FBToken = '',
port = 443,
options = {
@wok
wok / multi_statements_mysql2.rb
Created November 15, 2011 19:02
ActiveRecord MULTI_STATEMENTS with mysql2
# place in config/initalizers
module ActiveRecord
class Base
# Establishes a connection to the database that's used by all Active Record objects.
def self.mysql2_connection(config)
config[:username] = 'root' if config[:username].nil?
if Mysql2::Client.const_defined? :FOUND_ROWS
config[:flags] = Mysql2::Client::FOUND_ROWS | Mysql2::Client::MULTI_STATEMENTS
@ciaranarcher
ciaranarcher / golang-cheat.md
Last active December 27, 2018 14:26
golang cheatsheet

Types

type Vertex struct {
    Lat, Long float64
}

Maps

@visnup
visnup / listenOnPortOrSocketFile.js
Last active May 17, 2019 11:57
Listen on a TCP port or a UNIX socket file in node.js. Handle EADDRINUSE for the socket file by deleting it and re-listening.
var fs = require('fs')
, net = require('net')
, http = require('http')
, port = process.env.PORT;
var app = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
};
@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 
@samklr
samklr / ansible-gce.sh
Last active January 11, 2020 22:56
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