Skip to content

Instantly share code, notes, and snippets.

@nickwph
nickwph / repo-commands.sh
Created May 7, 2015 16:35
Nice Repo Commands
# update repo version
repo selfupdate --no-repo-verify
# reset all repos
repo forall -vc "git reset --hard"
# clean and delete unstaged changes
repo forall -vc "git clean -df"
# pull all repos
@nickwph
nickwph / build-jacoco.gradle
Created May 26, 2015 23:50
Gradle build file to set up variables for JaCoCo.
/**
* Created by Nicholas Wong <[email protected]>.
* Gradle build file to set up variables for JaCoCo.
* The following tasks will be created in normal circumstance.
*
* - Create JaCoCo HTML and XML Reports
* jacocoDebug
* jacocoRelease
*
* - Open JaCoCo HTML Report in Mac OSX
import java.util.Scanner;
public class Solution1 {
public static void main(String[] args) {
try {
// read in matrix
Scanner scanner = new Scanner(System.in);
int length = Integer.parseInt(scanner.nextLine());
int[][] matrix = new int[length][length];
for (int i = 0; i < length; i++) {
# node structure
class Node:
value = None
left = None
right = None
# constructor
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
@nickwph
nickwph / install-sublime-text-3.sh
Last active October 12, 2015 18:16
Sublime Text 3 on CentOS / RHEL
#!/bin/sh
# run this to install
# sudo su install-sublime-text-3.sh
# modify this if you need another version or or architecture
URL="http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3083_x64.tar.bz2"
SHORTCUT="[Desktop Entry]
Name=Sublime Text 3
Comment=Edit text files
@nickwph
nickwph / aosp-centos-7-building-guide.md
Last active October 13, 2021 02:42
CentOS 7 AOSP Building Guide

CentOS 7 AOSP Building Guide

install libraries

# fetch source
sudo yum install git
sudo yum install wget
# to compile
sudo yum install java-1.7.0-openjdk
@nickwph
nickwph / aosp-jack-error-fix.md
Created October 13, 2015 20:00
Error when Building AOSP

if you encounter this error

out/host/linux-x86/bin/jack: line 131: 31049 Killed                  $SERVER_PRG $SERVER_PORT_SERVICE $SERVER_PORT_ADMIN $SERVER_COUNT $SERVER_NB_COMPILE $SERVER_TIMEOUT >> $SERVER_LOG 2>&1
ERROR: Cannot launch Jack server
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex] Error 41
make: *** Waiting for unfinished jobs....

its because ~/.jack has an incorrect permission you can fix it with

Idea

# stack: a stack that store the current combination
# items: available items, each item has a value
# available_space: the spaces left of the current combination
# index: the index of items it is going to match
function find_combinations_recursively(stack, items, available_space, index):
    # check for invalid target or value
    value = items[index]

Define Node

static class Node {
    int value;
    Node left, right;
}

Depth First Recursive Traversal (Pre-order)

Define Node

static class Node {
    int value;
    Node left, right;
}

Breathe First Iterative Traversal