Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Learning blockchain.

Allan JL AllanJunLi

💭
Learning blockchain.
  • Sydney
View GitHub Profile
@AllanJunLi
AllanJunLi / RegexTest.java
Created Jun 1, 2018
Learning Java regular expression
View RegexTest.java
public class RegexTestStrings {
public static final String TEST = "This is my small example string which I'm going to use for pattern matching.";
public static void main(String[] args) {
System.out.println(TEST.matches("\\w.*"));
// split by whitespace
String[] splitStr = TEST.split("\\s+");
System.out.println(splitStr.length);
for (String str : splitStr) {
System.out.println(str);
@AllanJunLi
AllanJunLi / BlockChain.java
Last active Nov 6, 2018
Java implementation of blockchain concept
View BlockChain.java
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collection;
import java.util.List;
public class BlockChain {
@AllanJunLi
AllanJunLi / pom.xml
Created Jun 7, 2017 — forked from aelkz/pom.xml
JSF 2 (primefaces) + Wildfly 10 + CDI configuration (pre-built maven pom.xml)
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>br.com.aelkz</groupId>
<artifactId>JSFCDIWildlfyDemo</artifactId>
<version>1.0-SNAPSHOT</version>
@AllanJunLi
AllanJunLi / constructor.js
Created Aug 16, 2015
JavaScript class constructor
View constructor.js
function Circle(radius) {
this.radius = radius;
this.area = function() {
return this.radius * this.radius * Math.PI;
};
}
var instance = {};
Circle.call(instance, 5);
instance.area();
@AllanJunLi
AllanJunLi / greeter.js
Last active Aug 29, 2015
JS function closure
View greeter.js
function greeter(saluatation) {
var counter = 0; // If in java counter needs to be defined as final
var prefix = '. ' + saluatation + ' ';
return function (name) { // is bound to counter and prefix, (we call the variables that we are bound to closure)
counter++; // same reference to the outter counter, therefore keeps state
return counter + prefix + name + '!';
};
}
var greet = greeter('Hello');