This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { createStore, combineReducers } from 'redux' | |
import { Provider, connect } from 'react-redux'; | |
import { Link, Router, Route, IndexRoute, browserHistory } from 'react-router' | |
import { syncHistoryWithStore, routerReducer } from 'react-router-redux' | |
const reducer = combineReducers({ | |
products: (state = []) => state, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.franzwong</groupId> | |
<artifactId>test-app01</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<properties> | |
<guice.version>4.0</guice.version> | |
<common-io.version>2.4</common-io.version> | |
<java.version>1.8</java.version> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER=nodejs | |
PIDFILE=/var/run/sample.pid | |
SCRIPT=/home/$USER/sample/index.js | |
NVM_SCRIPT=/home/$USER/.nvm/nvm.sh | |
start() { | |
echo "Starting service" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# switch apt mirror | |
sudo sed -i 's/http:\/\/archive\.ubuntu\.com/http:\/\/ftp\.cuhk\.edu\.hk\/pub\/Linux/g' /etc/apt/sources.list | |
sudo sed -i 's/http:\/\/security\.ubuntu\.com/http:\/\/ftp\.cuhk\.edu\.hk\/pub\/Linux/g' /etc/apt/sources.list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sudo docker run -it --rm -p 3000 -v /var/run/docker.sock:/var/run/docker.sock rwwa/test_service | |
var http = require('http'); | |
var hostname = process.env['HOSTNAME']; | |
console.log('hostname: ' + hostname); | |
function getContainerInfo() { | |
var options = { | |
socketPath: '/var/run/docker.sock', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AmazonS3 s3 = new AmazonS3Client(new BasicAWSCredentials("userName", "password")); | |
s3.setEndpoint("s3-ap-southeast-1.amazonaws.com"); | |
ObjectMetadata metadata = new ObjectMetadata(); | |
metadata.setContentType("image/jpeg"); | |
PutObjectRequest req = new PutObjectRequest("my-bucket", "test.jpg", new FileInputStream("/Users/user/images/test.jpg"), metadata); | |
req.withCannedAcl(CannedAccessControlList.PublicRead); | |
req.withStorageClass(StorageClass.ReducedRedundancy); | |
PutObjectResult res = s3.putObject(req); | |
System.out.println(res.getContentMd5()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ~/src ~/src/java ~/src/javascript ~/src/docker | |
mkdir ~/dev | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
brew update | |
brew tap caskroom/cask | |
brew tap caskroom/versions | |
brew cask install sublime-text3 | |
brew cask install virtualbox | |
brew cask install java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.franzwong.codepiece.java.freemarker.freemarker001; | |
public class DataModel { | |
private String name; | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.franzwong.codepiece.java.ehcache; | |
import net.sf.ehcache.Cache; | |
import net.sf.ehcache.CacheManager; | |
import net.sf.ehcache.Element; | |
public class MainApplication { | |
public static void main(String[] args) { | |
CacheManager manager = CacheManager.create(); | |
manager.addCache("myCache"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some browsers do not support Object.create | |
if (typeof Object.create === 'undefined') { | |
Object.create = function(prototype) { | |
function C() {} | |
C.prototype = prototype; | |
return new C(); | |
} | |
} | |
function Actor(name) { |