Skip to content

Instantly share code, notes, and snippets.

View xnnyygn's full-sized avatar
🎯
Focusing

xnnyygn xnnyygn

🎯
Focusing
View GitHub Profile
class Foo
INSTANCE = Foo.new(1)
def initialize(arg0)
@arg0 = arg0
end
end
# run me in irb, and you will get this error
@xnnyygn
xnnyygn / ParseQueryString.java
Created October 21, 2014 07:10
a simple java program to parse query string
public class ParseQueryString {
public static void main(String[] args) {
String queryString = "foo=a&bar=b";
for(String pair : queryString.split("&")) {
int index = pair.indexOf('=');
// -1 means not found
// 0 means at beginnging, e.g '=a'
if(index <=0) {
continue;
}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class Dijkstra {
class VectorAndDistance {
@xnnyygn
xnnyygn / BinarySearchTree.java
Created November 26, 2013 06:23
binary search tree in java
import java.util.Iterator;
import java.util.LinkedList;
public class BinarySearchTree<T extends Comparable<T>> implements Iterable<T> {
// tree node
class Node {
T value;
Node leftChild;
Node rightChild;
@xnnyygn
xnnyygn / validation-form-select-by-class
Created August 22, 2012 07:51
Test html for validation two form with same class
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<style type="text/css">
* { font-family: Verdana; font-size: 96%; }
label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
@xnnyygn
xnnyygn / hobbies.scala
Created June 8, 2012 06:22
My first code example to post on posterous
object Hobbies {
def main(args[]: String){
println(List("Scala", "Java", "ACG", "Linux", "etc").mkString(", "))
}
}