Skip to content

Instantly share code, notes, and snippets.

@khoa-le
khoa-le / gist:751f0fac23ac760ffb66
Created May 24, 2015 01:29
Find and replace a character in a string in Go
package main
import (
"fmt"
"strings"
)
func main() {
str := " This string has many many spaces that need to be replaced "
@khoa-le
khoa-le / gist:2527b51748f9afe521c3
Last active August 29, 2015 14:21
How to write CSV data to file
package main
import (
"encoding/csv"
"fmt"
"os"
)
func main() {
csvfile, err := os.Create("output.csv")
@khoa-le
khoa-le / gist:d2b486a2de72f22b0bea
Created May 24, 2015 01:55
Implementing class(OOP style)
package main
import (
"fmt"
)
type SayHelloIntFace interface {
SayHello()
}
@khoa-le
khoa-le / gist:9b04a4f6be5969a23a82
Created May 24, 2015 07:30
Template Parse function in Golang html/template
package main
import (
"fmt"
"html/template"
"os"
)
func main() {
t := template.New("HELLO")
var templates = template.Must(t.ParseFiles("defaultTemplate.html"))
data := map[string]interface{}{
@khoa-le
khoa-le / gist:39c1d147b18a787ea281
Created May 24, 2015 07:42
Golang Automatic Reloads
#!/bin/bash
# The binary is most likely to have the current directory name
PROCESS=${PWD##*/}
# We kill the previous process
killall ${PROCESS}
# We launch the process
go build
@khoa-le
khoa-le / gist:d85f2b726062b222f577
Created June 30, 2015 08:59
Install PHP 7 from source
#!/bin/bash
# PHP 7
# Dependencies
apt-get update
apt-get install -y \
git-core \
autoconf \
bison \
@khoa-le
khoa-le / gist:c7b8f2a85bcc5929c965
Created July 6, 2015 06:18
Installing ghost with nginx proxy-cache
upstream ghost_upstream {
server 127.0.0.1:2368;
keepalive 64;
}
proxy_cache_path /var/run/cache levels=1:2 keys_zone=STATIC:75m inactive=24h max_size=512m;
server {
server_name domain.com;
add_header X-Cache $upstream_cache_status;
@khoa-le
khoa-le / bash
Created September 17, 2015 16:26
run command when use rvm
source /etc/profile.d/rvm.sh
@khoa-le
khoa-le / symfony.nginx.conf
Created October 20, 2015 03:50
Symfony Nginx Config
server {
listen 8001;
server_name dev.employer.vietnamworks.com;
#charset utf-8;
#access_log /var/log/nginx/log/host.access.log;
error_log /var/log/nginx/error.log;
root /home/khoa/Projects/employerdashboard/web;
location / {
try_files $uri /app_dev.php$is_args$args;
@khoa-le
khoa-le / bash
Last active October 21, 2015 04:26
Install php extension on Mac
#Install mcrypt extension php
brew install autoconf mcrypt
#download source php
cd php/ext/mcrypt
/usr/local/Cellar/php55/5.5.30/bin/phpize
./configure
make
sudo make install