Skip to content

Instantly share code, notes, and snippets.

View juehan's full-sized avatar

John.L juehan

  • Sydney, Australia
View GitHub Profile
@juehan
juehan / PythonChallenge02.py
Created February 13, 2012 11:53
Python Challenge Level2
f = open("pythonchallenge2.txt", "r")
l = []
try:
for line in f:
for c in line:
if c.isalpha():
l.append(c)
finally:
f.close()
@juehan
juehan / PythonChallenge1.py
Created February 13, 2012 11:09
Python Challenge Level 1
from string import maketrans
intab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
outtab = "CDEFGHIJKLMNOPQRSTUVWXYZAB"
transtab = maketrans(intab, outtab)
mystr = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
mystrUpper = mystr.upper()
print mystrUpper.translate(transtab).lower()
@juehan
juehan / move10.cpp
Created December 23, 2011 16:02
C++11 move sample01
#include <vector>
#include <ctime>
#include <iostream>
class X
{
private:
std::vector<int> m_vec;
public:
X() : m_vec(100000)
@juehan
juehan / GenericFactoryFunc
Created December 14, 2011 05:01
generic factory function
#include <memory>
#include <string>
#include <iostream>
//Example class
class Dog
{
public:
explicit Dog(std::string& name) : m_name(name), m_age(1){}