This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import SimpleHTTPServer, BaseHTTPServer, SocketServer, socket, time, sys | |
class ThreadedHTTPServer(SocketServer.ThreadingMixIn, | |
BaseHTTPServer.HTTPServer) : | |
""" | |
New features w/r to BaseHTTPServer.HTTPServer: | |
- serves multiple requests simultaneously | |
- catches socket.timeout and socket.error exceptions (raised from |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Denary2Binary(list): | |
'''convert denary integer n to binary string bStr''' | |
result = [] | |
bStr = '' | |
for n in list: | |
print "n is %s" %n | |
if n < 0: raise ValueError, "must be a positive integer" | |
if n == 0: return '0' | |
while n > 0: | |
bStr = str(n % 2) + bStr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert a decimal (denary, base 10) integer to a binary string (base 2) | |
# tested with Python24 vegaseat 6/1/2005 | |
def Denary2Binary(n): | |
'''convert denary integer n to binary string bStr''' | |
bStr = '' | |
if n < 0: raise ValueError, "must be a positive integer" | |
if n == 0: return '0' | |
while n > 0: | |
bStr = str(n % 2) + bStr | |
n = n >> 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import pickle | |
import yajl | |
try: | |
import cjson | |
except ImportError: | |
cjson = None | |
try: | |
import simplejson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.OutputStream; | |
import java.security.KeyStore; | |
import java.security.MessageDigest; | |
import java.security.cert.CertificateException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function getProtectedProperty($class, $propertyName) | |
{ | |
$reflectObj = new \ReflectionObject($class); | |
$extensions = $reflectObj->getProperty($propertyName); | |
$extensions->setAccessible(true); | |
return $extensions->getValue($class); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function setProtectedProperty($class, $propertyName, $setValue) | |
{ | |
$reflectObj = new \ReflectionObject($class); | |
$extensions = $reflectObj->getProperty($propertyName); | |
$extensions->setAccessible(true); | |
$extensions->setValue($class, $setValue); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function runProtectedFunction($class, $methodName, $args = null) | |
{ | |
$reflectMethod = new \ReflectionMethod($class,$methodName); | |
$reflectMethod->setAccessible(true); | |
if ($args == null) | |
{ | |
return $reflectMethod->invoke($class); | |
} else | |
{ | |
return $reflectMethod->invokeArgs($class, $args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Random generator in range | |
* | |
* @param minimum Number | |
* @param maximum Number | |
* @return randomNumber | |
*/ | |
public int randomGenerator(int minimum, int maximum) { | |
Random rn = new Random(); | |
int range = maximum - minimum + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->markTestSkipped('This test is scipped '); |
OlderNewer