Skip to content

Instantly share code, notes, and snippets.

View lzhoucs's full-sized avatar
🏠
Working from home

Liang Zhou lzhoucs

🏠
Working from home
View GitHub Profile
@lzhoucs
lzhoucs / 00.nodejs programs
Last active August 29, 2015 14:05
Simple tools and programs written in Node.js
title file
@lzhoucs
lzhoucs / scope1.md
Last active August 29, 2015 14:25
javascript variable scope demo

In the following example:

  • i is defined; j is undefined but declared; k is undeclared thus causing error;
  • indx is hoisted to the top of the function.
(function () {
  var i = 1;
  var j;
  console.log("i : " + i); // i : 1
  console.log("j : " + j); // j : undefined
 //console.log("k : " + k);// ReferenceError: k is not defined
@lzhoucs
lzhoucs / bit-manipulation-tricks.md
Last active November 6, 2015 06:55
bit manipulation tricks
  • drop the first bit
x >> 1;
  • drop LSB (the least Significant bit)
x & (x - 1);
  • extracts the lowest set bit of x (all other bits are cleared)
@lzhoucs
lzhoucs / c#.md
Last active November 13, 2015 23:20
The beauty of c# compared to java
  • Access modifier

protected internal can block any third party code outside of the assembly from subclassing/overriding methods inside the assembly.

  • equals

Object.ReferenceEquals() can check reference equality when hashcode()/equals() have been overriden to compare object equality between two objects. In java we can only check either object equality or reference equality, but not both.

  • package/code organization
@lzhoucs
lzhoucs / css3box-template.html
Last active December 16, 2015 02:09
A simple css3 box effect for div.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<style type="text/css">
div {
width : 400px;
@lzhoucs
lzhoucs / 00.web dev templates
Last active December 16, 2015 08:29
templates to for web development.
title file
@lzhoucs
lzhoucs / persistence.xml
Created April 21, 2013 19:13
JPA 2 persistence.xml example with hibernate and h2
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="punit1">
<jta-data-source>java:/DefaultDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
@lzhoucs
lzhoucs / codeStyle.html
Last active December 21, 2015 13:09
A very simple css to style code within <pre>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code style</title>
<style>
pre {
padding: 5px;
border-style: solid;
border-width: 1px;
@lzhoucs
lzhoucs / 00.Singleton Pattern in Spring
Last active December 23, 2015 02:49
A singleton pattern from Spring in Action 3rd
title file
@lzhoucs
lzhoucs / .gitignore
Created October 31, 2013 09:35
git ignore file
# intellij project files #
##########################
.idea/
*.iml
# eclipse project files #
#########################
.classpath
.project
.settings/