Skip to content

Instantly share code, notes, and snippets.

Nicholas Wong nickwph

Block or report user

Report or block nickwph

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View build-checkstyle.gradle
/**
* Created by Nicholas Wong <nickwph@gmail.com>.
* Github Gist: https://gist.github.com/nickwph/de0dd805e29fe3bcba476b6126459259
* Gradle build file to set up variables for checkstyle.
*/
apply plugin: 'checkstyle'
checkstyle {
configFile file('checkstyle-config.xml')
showViolations true
View build-findbugs.gradle
/**
* Created by Nicholas Wong <nickwph@gmail.com>.
* Github Gist: https://gist.github.com/nickwph/8e757fa1fff9c52a39a6a5a485fdc900
* Gradle build file to set up variables for findbugs.
* The following tasks will be created in normal circumstance.
*
* - Create FindBugs XML Report
* findbugsDebug
* findbugsRelease
*
View CALayer+Animate.swift
import Foundation
extension CALayer {
public func animate() -> CALayerAnimate {
return CALayerAnimate(layer: self)
}
}
public class CALayerAnimate {
View temp-solution.gradle
// temporarily solution: place generated code into source directory
project.afterEvaluate {
def variants
if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.test")) {
variants = project.android.applicationVariants
} else if (project.plugins.hasPlugin("com.android.library")) {
variants = project.android.libraryVariants
} else {
throw new Exception("The android application or library plugin must be applied to the project")
}
View setup_android-sdk.sh
# filtering function from sdk list
function get_id_with_regex {
android list sdk --all --extended | grep $1 | sed 's/.*"\(.*\)".*/\1/g' | tr '\n' ','
}
# grep ids
INSTALL_FILTER=$(get_id_with_regex 'build-tools') # build-tools-*
INSTALL_FILTER+=$(get_id_with_regex '"android-\(1[5-9]\|[2-9][0-9]\)') # android-15 to android-99
INSTALL_FILTER+='tools,'
INSTALL_FILTER+='platform-tool,'
View BasicPractice_BreatheFirstTraversal.md

Define Node

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

Breathe First Iterative Traversal

View BasicPractice_DepthFirstTraversal.md

Define Node

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

Depth First Recursive Traversal (Pre-order)

View BasicPractice_Snapsack.md

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]
@nickwph
nickwph / aosp-jack-error-fix.md
Created Oct 13, 2015
Error when Building AOSP
View aosp-jack-error-fix.md

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

@nickwph
nickwph / aosp-centos-7-building-guide.md
Last active Dec 15, 2018
CentOS 7 AOSP Building Guide
View aosp-centos-7-building-guide.md

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
You can’t perform that action at this time.