Skip to content

Instantly share code, notes, and snippets.

View simtse's full-sized avatar

Simon Tse simtse

View GitHub Profile

Content Streaming Architecture Diagram

What's in the Diagram:

  1. Complete System Architecture (First Mermaid diagram) Shows how the Presenter implements StreamableCursorPreserving The Text structure (blocks → spans → words) Where text parsing happens (in totalStreamingUnits and withCompletedStreamingUnits) How StreamableCursor and StreamableAccounting interact The complete streaming loop execution
@simtse
simtse / anagram.java
Created September 16, 2016 16:13
two string anagram?
// Solution #1: Sort the strings
boolean anagram(String s, String t) {
return sort(s) == sort(t);
}
// Solution #2: Check if the two strings have identical counts for each unique char.
public static boolean anagram(String s, String t) {
if (s.length() != t.length()) return false;
int[] letters = new int[256];
int num_unique_chars = 0;
@simtse
simtse / reverse-add.java
Last active September 16, 2016 16:03
Adding two linked lists of single digits that are reverse ordered
// We can implement this recursively by adding node by node, just as we would digit by digit.
// 1. result.data = (node1 + node2 + any earlier carry) % 10
// 2. if node1 + node2 > 10, then carry a 1 to the next addition.
// 3. add the tails of the two nodes, passing along the carry.
LinkedListNode addLists(LinkedListNode l1, LinkedListNode l2, int carry) {
if (l1 == null && l2 == null) {
return null;
}
LinkedListNode result = new LinkedListNode(carry, null, null);
@simtse
simtse / maven_push.gradle
Created December 22, 2015 02:57
Extending the Maven task installArchives to utilize the values set in the gradle.properties.
task installArchives(type: Upload) {
description "Installs the artifacts to the local Maven repository."
configuration = configurations['archives']
repositories {
mavenDeployer {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
repository url: "file://${System.properties['user.home']}/.m2/repository"
@simtse
simtse / library-gradle.properties
Created December 22, 2015 02:15
Library project's gradle.properties that specifies the location of the repository and the System user's gradle.properties in ~/.gradle/
GROUP=com.companyname.center
VERSION_NAME=0.0.1
POM_ARTIFACT_ID=private-library
# ...
ARTIFACT_REPO=http://yourdomain.com/artifactory/companyname-local/
ARTIFACT_SNAPSHOT_REPO=http://yourdomain.com/artifactory/companyname-local/
@simtse
simtse / maven_push.gradle
Last active December 22, 2015 02:09
Snippet of the uploadArchives task needing a username and password from getRepositoryUsername() and getRepositoryPassword()
def getReleaseRepositoryUrl() {
return ARTIFACT_REPO
}
def getSnapshotRepositoryUrl() {
return ARTIFACT_SNAPSHOT_REPO
}
def getRepositoryUsername() {
return System.properties['username']
@simtse
simtse / gradle.properties
Created December 22, 2015 00:57
Example of a library that will be deployed to the Snapshot repo instead of the release repo.
GROUP=com.companyname.center
VERSION_NAME=0.1.2-SNAPSHOT
POM_ARTIFACT_ID=private-library
GROUP=com.companyname.center
VERSION_NAME=0.0.1
POM_ARTIFACT_ID=private-library
POM_NAME=Library Template
POM_DESCRIPTION=A description for this library
POM_PACKAGING=aar
POM_URL=https://github.com/simtse/LibraryTemplate
POM_SCM_URL=https://github.com/simtse/LibraryTemplate
@simtse
simtse / ConfiguredUploadArchives
Created December 22, 2015 00:09
Maven uploadArchives gradle task is extended to be configured by values set in gradle.properties
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
@simtse
simtse / MavenPushRepo
Last active December 21, 2015 23:51
Choosing which Maven repo to publish to based on Version Name
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getReleaseRepositoryUrl() {
return ARTIFACT_REPO
}
def getSnapshotRepositoryUrl() {
return ARTIFACT_SNAPSHOT_REPO