Skip to content

Instantly share code, notes, and snippets.

View kwokhou's full-sized avatar
🎯
Focusing

Andy Yong kwokhou

🎯
Focusing
View GitHub Profile
@kwokhou
kwokhou / boxstarter-winupdate
Created July 13, 2015 05:26
Boxstarter Install Windows Updates
Set-WindowsExplorerOptions -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-MicrosoftUpdate
Install-WindowsUpdate
Set-CornerNavigationOptions -EnableUsePowerShellOnWinX
Update-ExecutionPolicy
@kwokhou
kwokhou / run-wordpress-docker.bat
Last active November 13, 2015 02:09
Docker Wordpress + MySQL under docker-machine
# Initialized a mysql container and name it 'mysqldb' with a database name 'wordpress', and publish it under port 3306
# The container uses the mysql images v5.7
docker run --name mysqldb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -p 3306:3306 -d mysql:5.7
# To create a different mysql user instead of the root (Note: you still need to specify root password)
docker run --name mysqldb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=wordpress -p 3306:3306 -d mysql:5.7
# Run wordpress container and name it 'wordpress' and linking it with the mysql database (which named `mysqldb` previously)
docker run --name wordpress -e WORDPRESS_DB_PASSWORD=password -p 8080:80 --link mysqldb:mysql -d wordpress
@kwokhou
kwokhou / docker-compose.yml
Created September 5, 2016 00:58
Setup secure Docker Registry with Nginx and SSL
registry:
restart: always
image: registry:2
expose:
- "5000"
environment:
- REGISTRY_HTTP_SECRET=<PUT SOME SECRET TEXT HERE>
volumes:
- ./config.yml:/etc/docker/registry/config.yml:ro
proxy:
@kwokhou
kwokhou / config.azure.yml
Last active September 8, 2016 02:20
Docker Registry using Azure Blob Storage or AWS S3
version: 0.1
log:
fields:
service: registry
storage:
delete:
enabled: true
cache:
blobdescriptor: inmemory
azure:
@kwokhou
kwokhou / config.yml
Created September 5, 2016 01:04
Docker Registry using File system storage
version: 0.1
log:
fields:
service: registry
storage:
delete:
enabled: true
cache:
blobdescriptor: inmemory
filesystem:
@kwokhou
kwokhou / proxy.conf
Last active September 5, 2016 02:17
Nginx conf for Docker Registry
upstream docker-registry {
server registry:5000;
}
server {
listen 80;
server_name mydomain.com;
root /etc/nginx/html;
index index.html index.htm index.nginx-debian.html;
@kwokhou
kwokhou / template.rb
Created January 23, 2017 03:41
Rails 5 Template with Bootstrap 4
require 'net/http'
# Temporary fix until https://github.com/erikhuda/thor/issues/538 closed
gem 'thor', '0.19.1'
# configuration
gem 'figaro'
# security
if yes?("Would you like to install Devise?")
@kwokhou
kwokhou / urlhelper.js
Created February 13, 2017 00:52
Redirect to URL with query string parameter changed
var updateUrlParameter = function (uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (!value) {
@kwokhou
kwokhou / StringUtils.java
Created April 11, 2017 14:22
JAVA String Is Null Or Blank / Empty
/**
* Check if a String object is null or contain only spaces.
*
* @param s String object to check.
* @return TRUE if s is null or contain only spaces. FALSE if otherwise.
*/
public static boolean isNullOrBlank(String s) {
return s == null || s.trim().length() == 0;
}
@kwokhou
kwokhou / config.fish
Created May 3, 2017 14:18
Fish Prompt with Git integration
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end