Skip to content

Instantly share code, notes, and snippets.

View kenng's full-sized avatar
💭
calm

Ken Ng kenng

💭
calm
View GitHub Profile
@kenng
kenng / http_get.go
Created April 9, 2016 13:41 — forked from ijt/http_get.go
Example of using http.Get in go (golang)
package main
import (
"fmt"
"http"
"io/ioutil"
"os"
)
func main() {

#Introduction If you're a php developer on ubuntu, there comes the time where you have to install/reinstall your system. I did it already a few times and i decided to write down the steps for a typical web developer stack with php. This is for a developer machine and not for a live environment!

I hope it helps you too!

fyi @mheiniger and me started with an installer here: https://github.com/mheiniger/webdev-setup

@kenng
kenng / README.md
Created June 9, 2016 14:08 — forked from johan/README.md
JS debug breakpoint / log snippets

stopBefore.js

2min screencast

These tools inject a breakpoint, console.log or console.count in any function you want to spy on via stopBefore('Element.prototype.removeChild') or ditto stopAfter, logBefore / logAfter / logAround / logCount.

Works in Chrome DevTools and Safari Inspector; Firefox dev tools reportedly less so.

@kenng
kenng / my.css
Created June 24, 2016 00:56 — forked from anonymous/my.css
CSS Gradient Animation
background: linear-gradient(140deg, #086382, #a22cde);
background-size: 400% 400%;
-webkit-animation: AnimationName 21s ease infinite;
-moz-animation: AnimationName 21s ease infinite;
-o-animation: AnimationName 21s ease infinite;
animation: AnimationName 21s ease infinite;
@-webkit-keyframes AnimationName {
    0%{background-position:97% 0%}
    50%{background-position:4% 100%}
    100%{background-position:97% 0%}
@kenng
kenng / ID.js
Last active August 8, 2016 06:53
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@kenng
kenng / README.md
Created August 15, 2016 05:56 — forked from magnetikonline/README.md
Setting Nginx FastCGI response buffer sizes.

Nginx FastCGI response buffer sizes

By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is outlined at the Nginx ngx_http_fastcgi_module page document page.

Introduction

Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (i.e. it's not shared memory).

@kenng
kenng / detectcontenttype.go
Created September 6, 2016 06:02 — forked from rayrutjes/detectcontenttype.go
golang detect content type of a file
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
// Only the first 512 bytes are used to sniff the content type.
buffer := make([]byte, 512)
_, err = file.Read(buffer)
if err != nil {
<html lang="en-us"></html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" cntnt="IE=edge"/>
<title></title>
<meta name="viewport" cntnt="width=device-width, initial-scale=1, user-scalable=0, maximum-scale=1.0"/>
<meta name="description"/>
<link rel="stylesheet" href="css/.min.css"/>
<link rel="stylesheet" href="css/theme.min.css"/>
@kenng
kenng / golang-tls.md
Created October 27, 2016 07:26 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@kenng
kenng / app.js
Created November 2, 2016 22:00 — forked from Turbo87/app.js
webpack + font-awesome test
require('font-awesome/css/font-awesome.css');
document.body.innerHTML = '<i class="fa fa-fw fa-question"></i>';