Skip to content

Instantly share code, notes, and snippets.

View hanksudo's full-sized avatar
:octocat:
Follow your passion.

Hank Wang hanksudo

:octocat:
Follow your passion.
View GitHub Profile
@hanksudo
hanksudo / validateEmail.js
Last active December 13, 2015 22:19
JavaScript: Using Regular Expression to validate Email. Refer from: http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
{
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
},
{
"characters": "/",
"selector": "string.quoted.double.html,string.quoted.single.html, source.css"
@hanksudo
hanksudo / OneLinerGenerateTenRandomFile.sh
Last active December 14, 2015 15:09
One-liner shell script for generate ten random files
for ((i=1; i<=10; i++)); do dd if=/dev/urandom of=test-$i.bin bs=10k count=1; done
@hanksudo
hanksudo / OneLinerRenameMultiFiles.sh
Created March 7, 2013 05:48
One-liner shell script for rename multi files name or ext name
# replace extesion name .html to .php
for i in *.html; do mv "$i" "`echo $i | sed 's/\.html/.php/g'`"; done
# another way to replace extension
ls *.html | awk '{print("mv "$1" "$1)}' | sed 's/html/mak/2' | /bin/sh
@hanksudo
hanksudo / Python3ListExample.py
Last active December 14, 2015 18:48
Python 3: List Example
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Introducing Lists easy example
@author: Hank Wang <[email protected]>
@version: 20101010
"""
# Creating Lists
@hanksudo
hanksudo / Python3MultiplicationSample.py
Last active December 14, 2015 18:48
Multiplication Sample
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# filename: Multiplication.py <九九乘法>
# date: 2010-08-07
if __name__ == "__main__":
for i in range(2, 10):
for j in range(1, 10):
print(i, " x ", j, " = ", i*j) # method 1
#print("%d x %d = %d" % (i, j, i*j)) # method 2
@hanksudo
hanksudo / Multiplication.c
Created March 11, 2013 04:02
Multiplication Example in C
#include <stdio.h>
int main() {
int i, j;
for(i=2; i<10; i++) {
for(j=1; j<10; j++) {
printf("%d x %d = %d\n", i, j , i*j);
}
}
getchar();
@hanksudo
hanksudo / DemoBeautifulSoup.py
Last active December 14, 2015 18:48
Demo: Use BeautifulSoup parse HTML
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Demo: Use BeautifulSoup parse HTML
@author: Hank
@version: 2011/1/15
@updated: 2013/3/11
"""
@hanksudo
hanksudo / Python.sublime-build
Created March 11, 2013 04:36
Build Python program on Sublime Text
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env":{
"PYTHONPATH": "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
}
}
@hanksudo
hanksudo / ThreadingSample.py
Created March 11, 2013 07:27
Python: Threading Example
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Threading Example
@author: Hank Wang <[email protected]>
@version: 20101230
"""
import time