Skip to content

Instantly share code, notes, and snippets.

View ucheng's full-sized avatar
💭
😄

Yu-Cheng Wang ucheng

💭
😄
View GitHub Profile
@ucheng
ucheng / ShowCurrentTimeTask.java
Created July 7, 2012 02:43
Java Timer example
public class Main {
public static void main(String[] args) {
Timer timer = new Timer();
ShowCurrentTimeTask task = new ShowCurrentTimeTask();
timer.scheduleAtFixedRate(task, 0, 2000);
}
@ucheng
ucheng / ReadStringToJsonNode.java
Created July 16, 2012 06:42
Read String to JsonNode
package com.stanley;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
public class ReadStringToJsonNode {
@ucheng
ucheng / ReadStringToJsonNodeAndUpdateIt.java
Created July 18, 2012 06:14
Add or Update Json field value
package com.stanley;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
public class ReadStringToJsonNodeAndUpdateIt {
@ucheng
ucheng / ShortExecutionTimeTask.java
Created July 21, 2012 02:29
Timer schedule short execution time task
package com.stanley;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class ShortExecutionTimeTask {
public static void main(String[] args) {
@ucheng
ucheng / maven-layout.txt
Created July 22, 2012 16:27
Maven project Standard Directory Layout
my-app/
|-- pom.xml
|-- src
| |-- main
| | |-- assembly
| | |-- config
| | |-- filters
| | |-- java
| | |-- resources
| | `-- webapp
public class StringEquals {
public static void main(String[] args) {
jack();
jill();
jeff();
john();
}
public static void jack() {
String s1 = "hill5";
@ucheng
ucheng / git-create-a-repos
Last active February 7, 2021 13:13
Push fresh code to a GitHub repository
git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/ucheng/your-repos.git
git push -u origin master
@ucheng
ucheng / git-remove
Created May 2, 2013 10:39
Remove file or folder from a git repos
git rm --cached fileName
git rm -r --cached folderName
@ucheng
ucheng / increaseingCircle.pde
Last active December 17, 2015 00:19
A circle drawn using frame loop
int diam = 10;
void setup() {
size(400, 400);
frameRate(24);
noStroke();
fill(255,0,0);
background(255,255,0);
}
int diam = 10;
float centX, centY;
void setup() {
size(400, 400);
frameRate(24);
smooth();
centX = width/2;
centY = height/2;
stroke(0);