- Composition over inheritance
- Extract code to separate method instead of putting code comment
- Return early
- Don't ignore exception
- Avoid singleton pattern
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
#!/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
<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
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
FROM cassandra:3.0 | |
ENV LOCAL_JMX no | |
COPY jmxremote.password /etc/cassandra/jmxremote.password | |
RUN chown cassandra:cassandra /etc/cassandra/jmxremote.password | |
RUN chmod 400 /etc/cassandra/jmxremote.password | |
RUN sed -i '/monitorRole readonly/a cassandra readwrite' /etc/java-8-openjdk/management/jmxremote.access | |
RUN sed -i '/JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT/a\ | |
\ \ JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=192.168.99.100"\ | |
' /etc/cassandra/cassandra-env.sh | |
CMD ["cassandra", "-f"] |
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 main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func Quicksort(elements []int, low int, high int) { | |
if (high > low) { |
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
public class BinaryTreeNode<T> { | |
private T value; | |
private BinaryTreeNode<T> leftChild; | |
private BinaryTreeNode<T> rightChild; | |
public T getValue() { | |
return value; | |
} |
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 io.vertx.core.Vertx | |
import io.vertx.core.json.Json | |
import io.vertx.ext.web.Router | |
data class Person( | |
val name: String, | |
val nationality: String | |
) { | |
} |