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> | |
| #include "html.h" | |
| int main(int argc, char *argv[]) | |
| { | |
| html( | |
| head( | |
| title("Site Title"), | |
| script("http://test.com/test.js"), |
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
| static void _head(void) | |
| { | |
| const char *v; | |
| utils_page_head("Demo"); | |
| raw(<script type="text/javascript">); | |
| echo("var _debug = 0;"); | |
| echo("var cgi_var = "); | |
| cgi_json(); | |
| echo(";"); | |
| raw(</script>); |
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
| def coroutine(f): | |
| _co = f() | |
| return lambda : _co.next | |
| @coroutine | |
| def foo(): | |
| for i in xrange(5): | |
| yield i | |
| a = foo() |
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
| from itertools import izip | |
| def isiterable(o): | |
| try: | |
| it = iter(o) | |
| except TypeError: | |
| return False | |
| return True | |
| class Args(object): |
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
| # http://www.ptt.cc/bbs/Python/M.1349181219.A.3C5.html | |
| def main(): | |
| sum = lambda d: (lambda f,a:f(f,a))((lambda s,l,a=0:a if not l else s(s,l[1:],a+l[0])),d) | |
| print sum([3,3,2,2,1]) | |
| main() |
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
| void print_num(int n) | |
| { | |
| unsigned char buf[12] = {0}, *p = buf + 10; | |
| char minus = (n < 0); | |
| if(n < 0) n = -n; | |
| while(n) | |
| { | |
| *p-- = '0' + (n % 10); | |
| n /= 10; | |
| } |
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
| MCU ?= attiny2313 | |
| PROJ = test | |
| TARGET = $(PROJ).hex # $(PROJ).bin | |
| INC = | |
| LIBS = | |
| include ../000_common/make.rules | |
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
| http://www.doughellmann.com/articles/misc/dict-performance/ | |
| $ ./pypy-c --version | |
| Python 2.7.3 (e537e0093563, Oct 13 2012, 22:21:46) | |
| [PyPy 1.9.1-dev0 with GCC 4.4.4] | |
| $ ./pypy-c -m timeit -n 1000000 -r 5 -v 'dict()' | |
| raw times: 0.0186 0.00177 0.00134 0.00134 0.00234 | |
| 1000000 loops, best of 5: 0.00134 usec per loop |
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/python | |
| # -*- encoding: big5 -*- | |
| # http://10print.org/ | |
| from random import random as r | |
| print "\n".join(["".join([["\xa2\xac", "\xa2\xad"][int(0.5+r())] for i in xrange(40)]) for j in xrange(24)]) | |
| """ | |
| ╲╱╱╲╲╱╱╲╱╲╲╲╱╱╲╲╲╱╱╱╱╱╱╲╱╱╲╱╲╲╱╲╱╱╲╲╲╱╲╱ |
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/python | |
| import pygame | |
| from pygame import mixer as mixer | |
| import sys | |
| if len(sys.argv) == 1: | |
| sys.exit() | |
| try: | |
| pygame.init() |