This file contains hidden or 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
<xs:simpleType name="UPC-E-Barcode"> | |
<xs:annotation> | |
<xs:documentation> | |
Reference: http://www.barcodeisland.com/upce.phtml | |
The UPC-E barcode has 7 digits. | |
</xs:documentation> | |
</xs:annotation> | |
<xs:restriction base="xs:token"> | |
<xs:pattern value="[0-9]{7}"/> | |
</xs:restriction> |
This file contains hidden or 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 | |
# http://docs.python.org/dev/library/argparse.html | |
import argparse | |
if __name__=='__init__': | |
parser = argparse.ArgumentParser(description='') | |
args = parser.parse_args() | |
print(args) |
This file contains hidden or 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
#include <stdio.h> // PERROR(3) | |
#include <stdlib.h> // EXIT(3) | |
#include <sys/socket.h> // BIND(2) | |
int retval = bind( | |
/* int sockfd */ | |
/* const struct sockaddr *addr */ | |
/* socklen_t addrlen */ | |
); | |
if (retval == -1) { |
This file contains hidden or 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
#include <stdlib.h> | |
#include <signal.h> | |
/* | |
* Gracefully exits when Ctrl+C is pressed. | |
*/ | |
void sigint_handler(int signum) { | |
exit(0); | |
} |
This file contains hidden or 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
#include <stdint.h> | |
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
printf("sizeof(char): %lu\n", sizeof(char)); | |
printf("sizeof(unsinged char): %lu\n", sizeof(unsigned char)); | |
printf("sizeof(signed char): %lu\n", sizeof(signed char)); | |
printf("sizeof(int8_t): %lu\n", sizeof(int8_t)); | |
printf("sizeof(uint8_t): %lu\n", sizeof(uint8_t)); | |
printf("sizeof(short): %lu\n", sizeof(short)); |
This file contains hidden or 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
<html><body><h1>It works!</h1> | |
<p>This is the default web page for this server.</p> | |
<p>The web server software is running but no content has been added, yet.</p> | |
</body></html> |
This file contains hidden or 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 | |
# This script creates a daemon thread named 'watchdog_timer' that runs the watchdog_timer() function. | |
# The main thread sleeps in an infinite loop until you press control-C. | |
# Since the watchdog_timer thread is a daemon, exiting the main thread will exit the entire process. | |
import threading | |
import time | |
def watchdog_timer(): |
This file contains hidden or 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
# Make sure we have the basics. | |
sudo apt-get install build-essential | |
# Install the build dependencies for Python. | |
# Replace with python2.7 if your distro supports it. | |
sudo apt-get build-dep python2.6 python-gdbm python-bsddb3 | |
# Use pythonbrew to actually compile Python. | |
curl -kL http://xrl.us/pythonbrewinstall | bash | |
pythonbrew install 2.7.2 |
This file contains hidden or 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 functools | |
def typecheck(*args1,isclassmethod=False): | |
"""Python is a language with typed objects, but untyped references. This means that there is no compiler to help catch type errors at design time. This typecheck function acts as a function decorator so that you can declare the type of each function or method argument. At runtime, the types of these arguments will be checked against their declared types. | |
Example: | |
@typecheck(types.StringType, Decimal) | |
def my_function(s, d): | |
pass |
This file contains hidden or 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
# Copyright (c) 2011, Nathan Farrington | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# | |
# 2. Redistributions in binary form must reproduce the above copyright |