assorted-commits Mailing List for Assorted projects (Page 12)
Brought to you by:
yangzhang
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(9) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(86) |
Feb
(265) |
Mar
(96) |
Apr
(47) |
May
(136) |
Jun
(28) |
Jul
(57) |
Aug
(42) |
Sep
(20) |
Oct
(67) |
Nov
(37) |
Dec
(34) |
2009 |
Jan
(39) |
Feb
(85) |
Mar
(96) |
Apr
(24) |
May
(82) |
Jun
(13) |
Jul
(10) |
Aug
(8) |
Sep
(2) |
Oct
(20) |
Nov
(31) |
Dec
(17) |
2010 |
Jan
(16) |
Feb
(11) |
Mar
(17) |
Apr
(53) |
May
(31) |
Jun
(13) |
Jul
(3) |
Aug
(6) |
Sep
(11) |
Oct
(4) |
Nov
(17) |
Dec
(17) |
2011 |
Jan
(3) |
Feb
(19) |
Mar
(5) |
Apr
(17) |
May
(3) |
Jun
(4) |
Jul
(14) |
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
2012 |
Jan
(3) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
(5) |
Sep
(2) |
Oct
(3) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(9) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(10) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yan...@us...> - 2010-04-18 00:39:54
|
Revision: 1627 http://assorted.svn.sourceforge.net/assorted/?rev=1627&view=rev Author: yangzhang Date: 2010-04-18 00:39:48 +0000 (Sun, 18 Apr 2010) Log Message: ----------- updated readme for 0.7 release Modified Paths: -------------- python-commons/trunk/README Modified: python-commons/trunk/README =================================================================== --- python-commons/trunk/README 2010-04-18 00:30:35 UTC (rev 1626) +++ python-commons/trunk/README 2010-04-18 00:39:48 UTC (rev 1627) @@ -1,44 +1,68 @@ [documentation](doc) Overview --------- +======== Python Commons is a general-purpose library for Python. To get a sense of what it provides, please glance over the [documentation](doc). Requirements ------------- +============ -- [Python](http://python.org/) 2.5 +- [Python](http://python.org/) 2.6 - [setuptools](http://peak.telecommunity.com/DevCenter/setuptools) 0.6 Certain sub-modules have extra requirements: - `async` requires [Twisted](http://twistedmatrix.com/trac/) 2.5 -- `files` requires [path](http://www.jorendorff.com/articles/python/path/) 2.2 This library has only been tested on Linux. Setup ------ +===== To install, run `easy_install python-commons`, or download the source tarball and run `python setup.py install`. -Related Work ------------- +Related +======= +The code here generally tries to complement the code already available in a +number of other general-purpose utility libraries for Python: + +- [AIMA Utilities]: accompanies a popular AI textbook +- [itools] +- [Grizzled] +- [PyUtilib] +- [Py] + +See also: + - [ASPN Cookbook]: a valuable repository of Python snippets -- [AIMA Utilities]: accompaniment to a popular AI textbook [ASPN Cookbook]: http://aspn.activestate.com/ASPN/Cookbook/Python [AIMA Utilities]: http://aima.cs.berkeley.edu/python/utils.py +[itools]: http://www.hforge.org/itools +[Grizzled]: http://bmc.github.com/grizzled/ +[PyUtilib]: https://software.sandia.gov/trac/pyutilib +[Py]: http://codespeak.net/py/dist/ Changes -------- +======= -version 0.6, 2008-10-?? +version 0.7, 2010-04-17 +- released for gbookmark2delicious +- enhanced free_struct +- added recursion_guard decorator +- complete html2unicode +- wrap keys and values as strings in sqlhash +- logger should append by default +- added inet_nltoa, inet_hltoa +- internally use commons.path instead of (unmaintained) path.py + +version 0.6, 2009-06-03 + - to strs added unwrap, indent, unindent, remove_empty_lines, underline, dos2unix, quotejs, unicode2html, html2unicode, nat_lang_join, or_join, and_join This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-18 00:30:41
|
Revision: 1626 http://assorted.svn.sourceforge.net/assorted/?rev=1626&view=rev Author: yangzhang Date: 2010-04-18 00:30:35 +0000 (Sun, 18 Apr 2010) Log Message: ----------- use commons.path instead of (unmaintained) path.py Modified Paths: -------------- python-commons/trunk/src/commons/files.py Modified: python-commons/trunk/src/commons/files.py =================================================================== --- python-commons/trunk/src/commons/files.py 2010-04-18 00:18:13 UTC (rev 1625) +++ python-commons/trunk/src/commons/files.py 2010-04-18 00:30:35 UTC (rev 1626) @@ -30,7 +30,7 @@ import os, re, tempfile from cPickle import * -from path import path +from commons.path import path def soft_makedirs( path ): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-18 00:18:28
|
Revision: 1625 http://assorted.svn.sourceforge.net/assorted/?rev=1625&view=rev Author: yangzhang Date: 2010-04-18 00:18:13 +0000 (Sun, 18 Apr 2010) Log Message: ----------- todo on lazy logging Modified Paths: -------------- python-commons/trunk/src/commons/log.py Modified: python-commons/trunk/src/commons/log.py =================================================================== --- python-commons/trunk/src/commons/log.py 2010-04-18 00:18:04 UTC (rev 1624) +++ python-commons/trunk/src/commons/log.py 2010-04-18 00:18:13 UTC (rev 1625) @@ -7,6 +7,9 @@ Functions are mostly self-explanatory. """ +# TODO: consider adding other lazy logging functions that take a lambda. +# eg: debug(lambda: 'currently at %s items' % n)) + from strs import * from itertools import chain, imap import logging, logging.handlers, sys This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-18 00:18:22
|
Revision: 1624 http://assorted.svn.sourceforge.net/assorted/?rev=1624&view=rev Author: yangzhang Date: 2010-04-18 00:18:04 +0000 (Sun, 18 Apr 2010) Log Message: ----------- enhanced free_struct Modified Paths: -------------- python-commons/trunk/src/commons/structs.py Modified: python-commons/trunk/src/commons/structs.py =================================================================== --- python-commons/trunk/src/commons/structs.py 2010-04-18 00:17:44 UTC (rev 1623) +++ python-commons/trunk/src/commons/structs.py 2010-04-18 00:18:04 UTC (rev 1624) @@ -6,6 +6,7 @@ """ import copy, heapq, itertools, sys, unittest +from commons.decs import recursion_guard class bidict( object ): """Bi-directional dictionary; assumes 1:1 mappings.""" @@ -40,13 +41,34 @@ def __delitem__( self, k ): return dict.__delitem__( self, k.lower() ) +class pprint_mixin(object): + 'Mixin for pretty-printing free_structs.' + + @recursion_guard("<...>") + def __str__(self, nesting = 1): + attrs = [] + indentation = " " * nesting + for k, v in self.__dict__.iteritems(): + if not k.startswith("_"): + text = [indentation, k, " = "] + if isinstance(v, free_struct): + text.append(v.__str__(nesting + 1)) + else: + text.append(repr(v)) + attrs.append("".join(text)) + attrs.sort() + attrs.insert(0, self.__class__.__name__ + ":") + return "\n".join(attrs) + class free_struct( object ): """ - General-purpose namespace structure. + General-purpose Python object with a bunch of boilerplate utility + functionality built-in. Subclass-friendly. """ def __init__( self, d = {}, **args ): self.__dict__.update( d ) self.__dict__.update( args ) + @recursion_guard("<...>") def __repr__( self ): fields = ( '%s = %r' % ( name, value ) for name, value in self.__dict__.iteritems() ) @@ -54,6 +76,34 @@ def __eq__( self, other ): return type( self ) == type( other ) and \ self.__dict__ == other.__dict__ + def __ne__(self, other): return not (self == other) + def __add__(self, other): + """ + Return a copy of this but with additional attributes corresponding to + the items or attributes from the other operand, depending on if it's a + dict or an object, respectively. + """ + dup = copy.copy(self) + d = other if isinstance(other, dict) else other.__dict__ + dup.__dict__.update(d) + return dup + def __radd__(self, other): + """ + Return a copy of this but with additional attributes corresponding to + the items or attributes from the other operand, depending on if it's a + dict or an object, respectively. + """ + dup = copy.copy(self) + d = other if isinstance(other, dict) else other.__dict__ + dup.__dict__.update(d) + return dup + def __sub__(self, other): + """ + Return a copy of this but with the specified attributes removed. + """ + dup = copy.copy(self) + for attr in other: del dup[attr] + return dup class LazyObject( object ): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-18 00:17:50
|
Revision: 1623 http://assorted.svn.sourceforge.net/assorted/?rev=1623&view=rev Author: yangzhang Date: 2010-04-18 00:17:44 +0000 (Sun, 18 Apr 2010) Log Message: ----------- added recursion_guard decorator Modified Paths: -------------- python-commons/trunk/src/commons/decs.py Modified: python-commons/trunk/src/commons/decs.py =================================================================== --- python-commons/trunk/src/commons/decs.py 2010-04-18 00:17:33 UTC (rev 1622) +++ python-commons/trunk/src/commons/decs.py 2010-04-18 00:17:44 UTC (rev 1623) @@ -11,6 +11,26 @@ import functools, inspect, xmlrpclib from cPickle import * +def recursion_guard(retval, guard_name = "____recursion_guard"): + """ + Prevents a methods from recursively calling itself. On recursion, it will + return retval instead. Note that this only protects methods, not functions. + To implement something similar for functions may call for some thread-local + state or some stack-walking. + """ + def decorator(func): + @functools.wraps(func) + def wrapper(self, *args, **kw): + if getattr(self, guard_name, False): + return retval + setattr(self, guard_name, True) + try: + return func(self, *args, **kw) + finally: + setattr(self, guard_name, False) + return wrapper + return decorator + def wrap_callable(any_callable, before, after): """ Wrap any callable with before/after calls. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-18 00:17:39
|
Revision: 1622 http://assorted.svn.sourceforge.net/assorted/?rev=1622&view=rev Author: yangzhang Date: 2010-04-18 00:17:33 +0000 (Sun, 18 Apr 2010) Log Message: ----------- complete html2unicode Modified Paths: -------------- python-commons/trunk/src/commons/strs.py Modified: python-commons/trunk/src/commons/strs.py =================================================================== --- python-commons/trunk/src/commons/strs.py 2010-04-15 20:57:15 UTC (rev 1621) +++ python-commons/trunk/src/commons/strs.py 2010-04-18 00:17:33 UTC (rev 1622) @@ -12,7 +12,6 @@ dos2unix format html2unicode -html_unicode indent nat_lang_join or_join @@ -137,23 +136,34 @@ return unicode_special.sub(lambda m: '&#%d;' % ord(m.group()), cgi.escape(s)) -html_unicode = re.compile(r'&#\d+;') -def html2unicode(s): - r""" - Sort of, but not really, a cgi.unescape() that works for Unicode. This is - useful as a filter on cgi.FieldStorage()['field'].value. In its raw form, - that's encoded using URL encoding. But if you submit a form with something - like (in Python string literal format) u'\u4e00&a', the server gets - '%26%2319968%3B%26a'. urllib.unquote() turns this into u'一&a', so - notice that what we receive is a URL encoding of a partial HTML encoding - - partial because the client only HTML-encoded the special character, and not - the rest. So, if we were to submit a form whose true value is - u'\u4e00一', this is impossible to distinguish from u'\u4e00\u4e00'. +def html2unicode(text): """ - # HTML special/Unicode char encoding is in base 10. - return html_unicode.sub(lambda m: unichr(int(m.group()[2:-1])), - unicode(s)) + Sort of a cgi.unescape (doesn't exist). Removes HTML or XML character + references and entities from a text string. + http://effbot.org/zone/re-sub.htm#unescape-html + """ + import htmlentitydefs + def fixup(m): + text = m.group(0) + if text[:2] == "&#": + # character reference + try: + if text[:3] == "&#x": + return unichr(int(text[3:-1], 16)) + else: + return unichr(int(text[2:-1])) + except ValueError: + pass + else: + # named entity + try: + text = unichr(htmlentitydefs.name2codepoint[text[1:-1]]) + except KeyError: + pass + return text # leave as is + return re.sub("&#?\w+;", fixup, text) + def nat_lang_join(xs, last_glue, two_glue = None, glue = ', '): """ Natural-language join. Join a sequence of strings together into a This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-15 20:57:22
|
Revision: 1621 http://assorted.svn.sourceforge.net/assorted/?rev=1621&view=rev Author: yangzhang Date: 2010-04-15 20:57:15 +0000 (Thu, 15 Apr 2010) Log Message: ----------- playing with enums and erasure Added Paths: ----------- sandbox/trunk/src/java/Enums.java Added: sandbox/trunk/src/java/Enums.java =================================================================== --- sandbox/trunk/src/java/Enums.java (rev 0) +++ sandbox/trunk/src/java/Enums.java 2010-04-15 20:57:15 UTC (rev 1621) @@ -0,0 +1,24 @@ +package com.relationalcloud.main; + +public class Sandbox { + + public static class Msg<E extends Enum<E>> { + int ordinal; + + E type() { + return null; + // Can't do the following due to erasure. + // return E.values()[ordinal]; + } + } + + enum PingPongMsg { + PING, PONG + } + + public static void main(String[] args) { + Msg<PingPongMsg> msg = new Msg<PingPongMsg>(); + msg.type(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-05 14:26:01
|
Revision: 1620 http://assorted.svn.sourceforge.net/assorted/?rev=1620&view=rev Author: yangzhang Date: 2010-04-05 14:25:55 +0000 (Mon, 05 Apr 2010) Log Message: ----------- added more to gcj06 Added Paths: ----------- problems/gcj/2006/matrixpermanent.txt problems/gcj/2006/squarecounting.py problems/gcj/2006/squarecounting.txt Property Changed: ---------------- problems/gcj/2006/cjam.cpp Property changes on: problems/gcj/2006/cjam.cpp ___________________________________________________________________ Deleted: svn:executable - * Added: problems/gcj/2006/matrixpermanent.txt =================================================================== --- problems/gcj/2006/matrixpermanent.txt (rev 0) +++ problems/gcj/2006/matrixpermanent.txt 2010-04-05 14:25:55 UTC (rev 1620) @@ -0,0 +1,92 @@ +Problem Statement + +The permanent of a nxn matrix A is equal to the sum of A[1][p[1]] * A[2][p[2]] * ... * A[n][p[n]] over all permutations p of the set {1, 2, ... , n}. +You will be given a String[] matrix, where each element contains a single space delimited list of integers. The jth integer in the ith element represents the value of A[i][j]. Return the int represented by the last four digits of the permanent of the given matrix. +Definition + +Class: +PermanentComputation +Method: +compute +Parameters: +String[] +Returns: +int +Method signature: +int compute(String[] matrix) +(be sure your method is public) + + +Constraints +- +matrix will contain between 1 and 16 elements, inclusive. +- +Each element of matrix will contain a list of integers, each separated by exactly one space. +- +Each element of matrix will contain exactly n integers, where n is the number of elements in matrix. +- +Each element will have length between 1 and 50 characters, inclusive. +- +Each element of matrix will contain no leading or trailing spaces. +- +Each integer in matrix will be between 0 and 10000, inclusive, and contain no leading zeroes. +Examples +0) + + +{ + "1 1", + "1 1"} +Returns: 2 +The permanent is equal to 1*1 + 1*1 = 2. +1) + + +{ + "1 2 3", + "4 5 6", + "7 8 9"} +Returns: 450 +The permanent is equal to 1*5*9 + 1*6*8 + 2*4*9 + 2*6*7 + 3*4*8 + 3*5*7 = 450. +2) + + +{ + "1 2 3 4", + "2 3 4 5", + "3 4 5 6", + "4 5 6 7"} +Returns: 4276 + +3) + + +{ + "1 1 1", + "2 2 2", + "3 3 3"} +Returns: 36 + +4) + + +{ + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", + "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"} +Returns: 8000 + +This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. Added: problems/gcj/2006/squarecounting.py =================================================================== --- problems/gcj/2006/squarecounting.py (rev 0) +++ problems/gcj/2006/squarecounting.py 2010-04-05 14:25:55 UTC (rev 1620) @@ -0,0 +1,105 @@ +#!/usr/bin/env python + +import sys + +debug = False +def dbg(*x): + if debug: + print ' '.join(map(str,x)) + +class Square: + def __init__(self,xmin,xmax,ymin,ymax): + self.xmin = xmin + self.ymin = ymin + self.xmax = xmax + self.ymax = ymax + def __str__(self): + return '%d %d %d %d' % (self.xmin, self.xmax, self.ymin, self.ymax) + +class E(Exception): pass + +class SquareCounting: + def howMany(self, grid): + squares = set() + Y = len(grid) + X = len(grid[0]) + for ymin in xrange(Y): + for xmin in xrange(X): + c = grid[ymin][xmin] + dbg( c ) + d = 1 + try: + if c == 'B': + #print 'ooga' + pass + for d in xrange(1,min(Y-ymin,X-xmin)+1): + xmax = xmin+d + ymax = ymin+d + if xmax >= X or ymax >= Y: + raise E + for xx in xrange(xmin,xmax+1): + dbg( 'xx',ymax,xx ) + if grid[ymax][xx] != c: + raise E + for yy in xrange(ymin,ymax+1): + dbg( 'yy',yy,xmax ) + if grid[yy][xmax] != c: + raise E + else: + raise E + except E: + dbg( 'E' ) + xmax = xmin+d-1 + ymax = ymin+d-1 + #print xmin, xmax, ymin, ymax + for square in squares: + #print '\t',square + if square.xmin <= xmin and square.xmax >= xmax and square.ymin <= ymin and square.ymax >= ymax: + break + elif square.xmin >= xmin and square.xmax <= xmax and square.ymin >= ymin and square.ymax <= ymax: + #print 'removing' + squares.remove(square) + else: + s = Square(xmin,xmax,ymin,ymax) + squares.add(s) + #print 'added square', s + return len(squares) + +sc=SquareCounting() +print sc.howMany( +'''AB +CD'''.split('\n')) +print sc.howMany( +'''AAB +AAB +BBB'''.split('\n')) +print sc.howMany( +'''AAA +AAA +AAA'''.split('\n')) +print sc.howMany( [ +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA", +"AAAAAAAAAA" +]) +print sc.howMany([ +"AAAAAABBB", +"AAAAAABBB", +"AAAAAABBB", +"AAAAAABBB", +"AAAAAABBB", +"BBBAAAAAA", +"BBBAAAAAA", +"BBBAAAAAA", +"BBBAAAAAA", +"BBBAAAAAA" +]) + +#main() Property changes on: problems/gcj/2006/squarecounting.py ___________________________________________________________________ Added: svn:executable + * Added: problems/gcj/2006/squarecounting.txt =================================================================== --- problems/gcj/2006/squarecounting.txt (rev 0) +++ problems/gcj/2006/squarecounting.txt 2010-04-05 14:25:55 UTC (rev 1620) @@ -0,0 +1,24 @@ +You are given a grid of characters, where each element describes a row. +A solid square is a contiguous n x n section of characters, +all of which have the same value. Return the number of solid +squares in grid that aren't contained in larger solid squares. + +Constraints +- +grid will contain between 1 and 10 elements, inclusive. +- +Each element of grid will contain between 1 and 10 characters, inclusive. +- +Each element grid will contain the same number of characters. +- +Each character in grid will be an uppercase letter ('A'-'Z'). + + +Examples +1) + +{"AAB", +"AAB", +"BBB"} +Returns: 6 +Here we have a 2 x 2 square of 'A's and 5 squares of 'B's (each 1 x 1). Thus we return 6. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-05 14:23:16
|
Revision: 1619 http://assorted.svn.sourceforge.net/assorted/?rev=1619&view=rev Author: yangzhang Date: 2010-04-05 14:23:10 +0000 (Mon, 05 Apr 2010) Log Message: ----------- added mit acm 2006 Added Paths: ----------- problems/mit-acm/2006/ problems/mit-acm/2006/3/ problems/mit-acm/2006/3/prog3.java problems/mit-acm/2006/3/prog3.py problems/mit-acm/2006/3/rot.py problems/mit-acm/2006/3/test problems/mit-acm/2006/4/ problems/mit-acm/2006/4/prob4.py problems/mit-acm/2006/4/test Added: problems/mit-acm/2006/3/prog3.java =================================================================== --- problems/mit-acm/2006/3/prog3.java (rev 0) +++ problems/mit-acm/2006/3/prog3.java 2010-04-05 14:23:10 UTC (rev 1619) @@ -0,0 +1,132 @@ +static enum Orient { left, upleft, upright, right, downright, downleft, inleft, inupleft, inupright, inright, indownright, indownleft } +static enum Angle { openRight, openLeft } +angles[left] = Angle.openRight +angles[upleft] = Angle.openLeft +angles[upright] = Angle.openRight +angles[right] = Angle.openLeft +angles[downright] = Angle.openRight +angles[downleft] = Angle.openLeft +angles[inleft] = Angle.openLeft +angles[inupleft] = Angle.openRight +angles[inupright] = Angle.openLeft +angles[inright] = Angle.openRight +angles[indownright] = Angle.openLeft +angles[indownleft] = Angle.openRight + angles.put( Orient.left, Angle.openRight ); + angles.put( Orient.upleft, Angle.openLeft ); + angles.put( Orient.upright, Angle.openRight ); + angles.put( Orient.right, Angle.openLeft ); + angles.put( Orient.downright, Angle.openRight ); + angles.put( Orient.downleft, Angle.openLeft ); + angles.put( Orient.inleft, Angle.openLeft ); + angles.put( Orient.inupleft, Angle.openRight ); + angles.put( Orient.inupright, Angle.openLeft ); + angles.put( Orient.inright, Angle.openRight ); + angles.put( Orient.indownright, Angle.openLeft ); + angles.put( Orient.indownleft, Angle.openRight ); + +for line in lines[1:]: + hexs = set() + pos = (0,0) + orient = None + for c in line.strip(): + if orient is None: + if c == '1': + orient = left + elif c == '2': + orient = inleft + else: + assert False + row,col = pos + if angle[orient] == open_left: +hex(pos.row,pos.col); +hex(pos.row-1,pos.col+1); +hex(pos.row+1,pos.col+1); +hex(pos.row,pos.col); +hex(pos.row-1,pos.col-1); +hex(pos.row+1,pos.col-1);; + else: + assert False + hexs.update(adjs) + if c == '1': + if (orient == Orient.left) { + orient = Orient.upleft; + pos = hex(pos.row-1,pos.col-1); + } else if (orient == Orient.upleft) { + orient = Orient.upright; + pos = hex(pos.row,pos.col+2); + } else if (orient == Orient.upright) { + orient = Orient.right; + pos = hex(pos.row+1,pos.col-1); + } else if (orient == Orient.right) { + orient = Orient.downright; + pos = hex(pos.row+1,pos.col+1); + } else if (orient == Orient.downright) { + orient = Orient.downleft; + pos = hex(pos.row,pos.col-2); + } else if (orient == Orient.downleft) { + orient = Orient.left; + pos = hex(pos.row-1,pos.col+1); + } else if (orient == Orient.inleft) { + orient = Orient.left; + pos = hex(pos.row-1,pos.col+1); + } else if (orient == Orient.inupleft) { + orient = Orient.upleft; + pos = hex(pos.row-1,pos.col-1); + } else if (orient == Orient.inupright) { + orient = Orient.upright; + pos = hex(pos.row,pos.col+2); + } else if (orient == Orient.inright) { + orient = Orient.right; + pos = hex(pos.row+1,pos.col-1); + } else if (orient == Orient.indownright) { + orient = Orient.downright; + pos = hex(pos.row+1,pos.col+1); + } else if (orient == Orient.indownleft) { + orient = Orient.downleft; + pos = hex(pos.row-1,pos.col-1); + else: + assert False + elif c == '2': + if orient == left: + orient = Orient.inleft; + pos = hex(pos.row-1,pos.col-1); + } else if (orient == Orient.upleft) { + orient = Orient.inupleft; + pos = hex(pos.row,pos.col+2); + } else if (orient == Orient.upright) { + orient = Orient.inupright; + pos = hex(pos.row+1,pos.col-1); + } else if (orient == Orient.right) { + orient = Orient.inright; + pos = hex(pos.row+1,pos.col+1); + } else if (orient == Orient.downright) { + orient = Orient.indownright; + pos = hex(pos.row,pos.col-2); + } else if (orient == Orient.downleft) { + orient = Orient.indownleft; + pos = hex(pos.row-1,pos.col+1); + } else if (orient == Orient.inleft) { + orient = Orient.indownleft; + pos = hex(pos.row-1,pos.col+1); + } else if (orient == Orient.inupleft) { + orient = Orient.inleft; + pos = hex(pos.row-1,pos.col-1); + } else if (orient == Orient.inupright) { + orient = Orient.inupleft; + pos = hex(pos.row,pos.col+2); + } else if (orient == Orient.inright) { + orient = Orient.inupright; + pos = hex(pos.row+1,pos.col-1); + } else if (orient == Orient.indownright) { + orient = Orient.inright; + pos = hex(pos.row+1,pos.col+1); + } else if (orient == Orient.indownleft) { + orient = Orient.indownright; + pos = hex(pos.row-1,pos.col-1); + } else { + assert false; + } + else: + assert False + print len( hexs ) Added: problems/mit-acm/2006/3/prog3.py =================================================================== --- problems/mit-acm/2006/3/prog3.py (rev 0) +++ problems/mit-acm/2006/3/prog3.py 2010-04-05 14:23:10 UTC (rev 1619) @@ -0,0 +1,134 @@ +#!/usr/bin/env python +import sys +lines = sys.stdin.readlines() +left, upleft, upright, right, downright, downleft = range(6) +inleft, inupleft, inupright, inright, indownright, indownleft = range(6,12) +xs = [ 'left', 'upleft', 'upright', 'right', 'downright', 'downleft', 'inleft', 'inupleft', 'inupright', 'inright', 'indownright', 'indownleft' ] + +def trans( c, orient, pos ): + row,col=pos + if c == '1': + if orient == left: + orient = upleft + pos = (row-1,col-1) + elif orient == upleft: + orient = upright + pos = (row,col+2) + elif orient == upright: + orient = right + pos = (row+1,col-1) + elif orient == right: + orient = downright + pos = (row+1,col+1) + elif orient == downright: + orient = downleft + pos = (row,col-2) + elif orient == downleft: + orient = left + pos = (row-1,col+1) + elif orient == inleft: + orient = left + pos = (row-1,col+1) + elif orient == inupleft: + orient = upleft + pos = (row-1,col-1) + elif orient == inupright: + orient = upright + pos = (row,col+2) + elif orient == inright: + orient = right + pos = (row+1,col-1) + elif orient == indownright: + orient = downright + pos = (row+1,col+1) + elif orient == indownleft: + orient = downleft + pos = (row,col-2) + else: + assert False + elif c == '2': + if orient == left: + orient = inleft + pos = (row-1,col-1) + elif orient == upleft: + orient = inupleft + pos = (row,col+2) + elif orient == upright: + orient = inupright + pos = (row+1,col-1) + elif orient == right: + orient = inright + pos = (row+1,col+1) + elif orient == downright: + orient = indownright + pos = (row,col-2) + elif orient == downleft: + orient = indownleft + pos = (row-1,col+1) + elif orient == inleft: + orient = indownleft + pos = (row-1,col+1) + elif orient == inupleft: + orient = inleft + pos = (row-1,col-1) + elif orient == inupright: + orient = inupleft + pos = (row,col+2) + elif orient == inright: + orient = inupright + pos = (row+1,col-1) + elif orient == indownright: + orient = inright + pos = (row+1,col+1) + elif orient == indownleft: + orient = indownright + pos = (row,col-2) + else: + assert False + else: + assert False + return orient, pos +def xxs( o ): + if o is None: + return 'None' + else: + return xs[o] +open_left, open_right = 0, 1 +angle = [open_right, open_left, open_right, open_left, open_right, open_left, + open_left, open_right, open_left, open_right, open_left, open_right] +for line in lines[1:]: + hexs = set() + orig = pos = (0,0) + first = orient = None + for c in line.strip(): + if first is None: + first = c + start = True + if c == '1': + origorient = orient = left + elif c == '2': + origorient = orient = inleft + else: + assert False + else: + start = False + + oldorient = orient + oldpos = pos + row,col = pos + + if angle[orient] == open_left: + adjs = [(row,col),(row-1,col+1),(row+1,col+1)] + elif angle[orient] == open_right: + adjs = [(row,col),(row-1,col-1),(row+1,col-1)] + else: + assert False + hexs.update(adjs) + + if not start: + orient, pos = trans(c,orient,pos) + #print c, xxs(oldorient), oldpos, xs[orient], pos, adjs + orient, pos = trans(line[0],orient,pos) + assert origorient == orient, orient + assert orig == pos, pos + print len( hexs ) Property changes on: problems/mit-acm/2006/3/prog3.py ___________________________________________________________________ Added: svn:executable + * Added: problems/mit-acm/2006/3/rot.py =================================================================== --- problems/mit-acm/2006/3/rot.py (rev 0) +++ problems/mit-acm/2006/3/rot.py 2010-04-05 14:23:10 UTC (rev 1619) @@ -0,0 +1,5 @@ +#!/usr/bin/env python +import sys +s = sys.stdin.read().strip() +print len(s) +for i in range(len(s)): print s; s=s[1:]+s[0] Property changes on: problems/mit-acm/2006/3/rot.py ___________________________________________________________________ Added: svn:executable + * Added: problems/mit-acm/2006/3/test =================================================================== --- problems/mit-acm/2006/3/test (rev 0) +++ problems/mit-acm/2006/3/test 2010-04-05 14:23:10 UTC (rev 1619) @@ -0,0 +1,5 @@ +4 +111111 +1221111211212121111212 +2111121121121121111222 +2221111211221121111222211112211112 Added: problems/mit-acm/2006/4/prob4.py =================================================================== --- problems/mit-acm/2006/4/prob4.py (rev 0) +++ problems/mit-acm/2006/4/prob4.py 2010-04-05 14:23:10 UTC (rev 1619) @@ -0,0 +1,82 @@ +#!/usr/bin/env python + +from commons import * +import sys +from itertools import * + +import psyco +psyco.full() + +debug = True +debug = False + +linez = sys.stdin.readlines() +while len(linez)>0: + lines = linez[:3] + del linez[:3] + k = int(lines[0].strip()) + a = [ int(x) - 1 for x in lines[1].split() ] + b = [ int(x) - 1 for x in lines[2].split() ] + n = 2*k + + seats = [ False ] * n + + indent = 0 + mincumcount = sys.maxint + + def go( ai, bi, cumcount ): + global indent,mincumcount + indent += 1 + if debug: + if cumcount >= mincumcount: + status = 'prune!' + else: + status = '' + print indent * ' ', 'go(%s,%s,%s)' % (ai,bi,cumcount), [{False:0,True:1}[x] for x in seats], mincumcount, status + if cumcount >= mincumcount: + ret = cumcount + else: + ret = -1 + assert ai <= len( a ) and bi <= len( b ) + + if ai < len( a ) and cumcount < mincumcount: + nextA = a[ai] + countLeft = len( [ i for i in seats[nextA:] if i ] ) + countRight = len( [ i for i in seats[:nextA] if i ] ) + count = min( countLeft, countRight ) + seats[nextA] = True + countA = go( ai+1, bi, cumcount + count ) + seats[nextA] = False + else: + countA = sys.maxint + + if bi < len( b ): + nextB = b[bi] + if nextB < k: + countLeft = len( [ i for i in seats[nextB:k] if i ] ) + countRight = len( [ i for i in seats[k:] if i ] ) + \ + len( [ i for i in seats[:nextB] if i ] ) + else: + countLeft = len( [ i for i in seats[:k] if i ] ) + \ + len( [ i for i in seats[nextB:] if i ] ) + countRight = len( [ i for i in seats[k:nextB] if i ] ) + count = min( countLeft, countRight ) + seats[nextB] = True + countB = go( ai, bi+1, cumcount + count ) + seats[nextB] = False + else: + countB = sys.maxint + + if ret == -1: + ret = min(countA,countB) + if ret == sys.maxint: + ret = cumcount + mincumcount = min( mincumcount, cumcount ) + print 'hit bottom', mincumcount + if debug: + print indent * ' ', ret + indent -= 1 + return ret + + print go(0,0,0) + #break Property changes on: problems/mit-acm/2006/4/prob4.py ___________________________________________________________________ Added: svn:executable + * Added: problems/mit-acm/2006/4/test =================================================================== --- problems/mit-acm/2006/4/test (rev 0) +++ problems/mit-acm/2006/4/test 2010-04-05 14:23:10 UTC (rev 1619) @@ -0,0 +1,31 @@ +3 +4 5 3 +6 2 1 +2 +1 2 +3 4 +2 +1 3 +2 4 +2 +2 1 +4 3 +2 +3 1 +4 2 +2 +1 2 +4 3 +2 +1 3 +4 2 +2 +2 1 +4 3 +2 +3 1 +4 2 +100 +0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 +100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-05 05:32:02
|
Revision: 1618 http://assorted.svn.sourceforge.net/assorted/?rev=1618&view=rev Author: yangzhang Date: 2010-04-05 05:31:56 +0000 (Mon, 05 Apr 2010) Log Message: ----------- added sigseg demo Added Paths: ----------- sandbox/trunk/src/c/sigseg/ sandbox/trunk/src/c/sigseg/sigseg.c sandbox/trunk/src/c/sigseg/sigseg.h Added: sandbox/trunk/src/c/sigseg/sigseg.c =================================================================== --- sandbox/trunk/src/c/sigseg/sigseg.c (rev 0) +++ sandbox/trunk/src/c/sigseg/sigseg.c 2010-04-05 05:31:56 UTC (rev 1618) @@ -0,0 +1,131 @@ +/** + * This source file is used to print out a stack-trace when your program + * segfaults. It is relatively reliable and spot-on accurate. + * + * This code is in the public domain. Use it as you see fit, some credit + * would be appreciated, but is not a prerequisite for usage. Feedback + * on it's use would encourage further development and maintenance. + * + * Author: Jaco Kroon <ja...@kr...> + * + * Copyright (C) 2005 - 2006 Jaco Kroon + */ +#define _GNU_SOURCE +#include <memory.h> +#include <stdlib.h> +#include <stdio.h> +#include <signal.h> +#include <ucontext.h> +#include <dlfcn.h> +#include <execinfo.h> +#ifndef NO_CPP_DEMANGLE +#include <cxxabi.h> +#endif + +#if defined(REG_RIP) +# define SIGSEGV_STACK_IA64 +# define REGFORMAT "%016lx" +#elif defined(REG_EIP) +# define SIGSEGV_STACK_X86 +# define REGFORMAT "%08x" +#else +# define SIGSEGV_STACK_GENERIC +# define REGFORMAT "%x" +#endif + +static void signal_segv(int signum, siginfo_t* info, void*ptr) { + static const char *si_codes[3] = {"", "SEGV_MAPERR", "SEGV_ACCERR"}; + + size_t i; + ucontext_t *ucontext = (ucontext_t*)ptr; + +#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64) + int f = 0; + Dl_info dlinfo; + void **bp = 0; + void *ip = 0; +#else + void *bt[20]; + char **strings; + size_t sz; +#endif + + fprintf(stderr, "Segmentation Fault!\n"); + fprintf(stderr, "info.si_signo = %d\n", signum); + fprintf(stderr, "info.si_errno = %d\n", info->si_errno); + fprintf(stderr, "info.si_code = %d (%s)\n", info->si_code, si_codes[info->si_code]); + fprintf(stderr, "info.si_addr = %p\n", info->si_addr); + for(i = 0; i < NGREG; i++) + fprintf(stderr, "reg[%02d] = 0x" REGFORMAT "\n", i, ucontext->uc_mcontext.gregs[i]); + +#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64) +# if defined(SIGSEGV_STACK_IA64) + ip = (void*)ucontext->uc_mcontext.gregs[REG_RIP]; + bp = (void**)ucontext->uc_mcontext.gregs[REG_RBP]; +# elif defined(SIGSEGV_STACK_X86) + ip = (void*)ucontext->uc_mcontext.gregs[REG_EIP]; + bp = (void**)ucontext->uc_mcontext.gregs[REG_EBP]; +# endif + + fprintf(stderr, "Stack trace:\n"); + while(bp && ip) { + if(!dladdr(ip, &dlinfo)) + break; + + const char *symname = dlinfo.dli_sname; +#ifndef NO_CPP_DEMANGLE + int status; + char *tmp = __cxa_demangle(symname, NULL, 0, &status); + + if(status == 0 && tmp) + symname = tmp; +#endif + + fprintf(stderr, "% 2d: %p <%s+%u> (%s)\n", + ++f, + ip, + symname, + (unsigned)(ip - dlinfo.dli_saddr), + dlinfo.dli_fname); + +#ifndef NO_CPP_DEMANGLE + if(tmp) + free(tmp); +#endif + + if(dlinfo.dli_sname && !strcmp(dlinfo.dli_sname, "main")) + break; + + ip = bp[1]; + bp = (void**)bp[0]; + } +#else + fprintf(stderr, "Stack trace (non-dedicated):\n"); + sz = backtrace(bt, 20); + strings = backtrace_symbols(bt, sz); + + for(i = 0; i < sz; ++i) + fprintf(stderr, "%s\n", strings[i]); +#endif + fprintf(stderr, "End of stack trace\n"); + exit (-1); +} + +int setup_sigsegv() { + struct sigaction action; + memset(&action, 0, sizeof(action)); + action.sa_sigaction = signal_segv; + action.sa_flags = SA_SIGINFO; + if(sigaction(SIGSEGV, &action, NULL) < 0) { + perror("sigaction"); + return 0; + } + + return 1; +} + +#ifndef SIGSEGV_NO_AUTO_INIT +static void __attribute((constructor)) init(void) { + setup_sigsegv(); +} +#endif Added: sandbox/trunk/src/c/sigseg/sigseg.h =================================================================== --- sandbox/trunk/src/c/sigseg/sigseg.h (rev 0) +++ sandbox/trunk/src/c/sigseg/sigseg.h 2010-04-05 05:31:56 UTC (rev 1618) @@ -0,0 +1,9 @@ +#ifndef __SIGSEGV_H__ +#define __SIGSEGV_H__ + +#ifdef __cplusplus +extern "C" +#endif +int setup_sigsegv(); + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-03 19:01:22
|
Revision: 1617 http://assorted.svn.sourceforge.net/assorted/?rev=1617&view=rev Author: yangzhang Date: 2010-04-03 19:01:16 +0000 (Sat, 03 Apr 2010) Log Message: ----------- added ashdown-residents, an early haskell script Added Paths: ----------- sandbox/trunk/src/one-off-scripts/ashdown-residents/ sandbox/trunk/src/one-off-scripts/ashdown-residents/README sandbox/trunk/src/one-off-scripts/ashdown-residents/res.lhs sandbox/trunk/src/one-off-scripts/ashdown-residents/res2.lhs Added: sandbox/trunk/src/one-off-scripts/ashdown-residents/README =================================================================== --- sandbox/trunk/src/one-off-scripts/ashdown-residents/README (rev 0) +++ sandbox/trunk/src/one-off-scripts/ashdown-residents/README 2010-04-03 19:01:16 UTC (rev 1617) @@ -0,0 +1,2 @@ +this is one of the earliest haskell scripts i've written (along with a revised +version based on feedback?); kept here for nostalgia/posterity Added: sandbox/trunk/src/one-off-scripts/ashdown-residents/res.lhs =================================================================== --- sandbox/trunk/src/one-off-scripts/ashdown-residents/res.lhs (rev 0) +++ sandbox/trunk/src/one-off-scripts/ashdown-residents/res.lhs 2010-04-03 19:01:16 UTC (rev 1617) @@ -0,0 +1,37 @@ +#!/usr/bin/env runhaskell + +> module Main where +> +> import System ( getArgs ) +> import Data.Char ( toLower ) +> import Data.List ( isSuffixOf ) +> import PreludeExts ( joinList, split ) +> import Maybe ( fromJust, fromMaybe, isJust, isNothing ) +> import Control.Monad ( guard, mplus ) +> +> dropSuffix suffix xs = if suffix `isSuffixOf` xs +> then take (length xs - length suffix) xs +> else xs +> +> main = do +> argv <- getArgs +> interact $ unlines . processLines . lines +> +> processLines :: [String] -> [String] +> processLines ls = [ after | before <- ls, Just after <- [processLine before]] +> where processLine :: String -> Maybe String +> processLine x = do let fields = split "," x +> res <- processFields fields +> return (joinList "," res) +> processFields :: [String] -> Maybe [String] +> processFields [room,fname,lname,gender,email1,email2,_,_,_,_,_,_] = +> let e1 = map toLower email1 +> e2 = map toLower email2 +> suffix = "@mit.edu" +> fix email = [room,fname,lname,gender,dropSuffix suffix email] +> in do guard (suffix `isSuffixOf` e1) +> return (fix e1) +> `mplus` +> do guard (suffix `isSuffixOf` e2) +> return (fix e2) +> processFields _ = Nothing \ No newline at end of file Property changes on: sandbox/trunk/src/one-off-scripts/ashdown-residents/res.lhs ___________________________________________________________________ Added: svn:executable + * Added: sandbox/trunk/src/one-off-scripts/ashdown-residents/res2.lhs =================================================================== --- sandbox/trunk/src/one-off-scripts/ashdown-residents/res2.lhs (rev 0) +++ sandbox/trunk/src/one-off-scripts/ashdown-residents/res2.lhs 2010-04-03 19:01:16 UTC (rev 1617) @@ -0,0 +1,33 @@ +#!/usr/bin/env runhaskell + +> module Main where +> +> import System ( getArgs ) +> import Data.Char ( toLower ) +> import Data.List ( isSuffixOf ) +> import PreludeExts ( joinList, split ) +> import Maybe ( fromJust, fromMaybe, isJust, isNothing ) +> +> dropSuffix suffix xs = if suffix `isSuffixOf` xs +> then take (length xs - length suffix) xs +> else xs +> +> main = do +> argv <- getArgs +> interact $ unlines . processLines . lines +> +> processLines :: [String] -> [String] +> processLines ls = [ fromJust after | before <- ls, after <- [processLine before], isJust after ] +> where processLine :: String -> Maybe String +> processLine = (\x -> if isNothing x then Nothing else Just $ joinList "," $ fromJust x) . processFields . split "," +> processFields :: [String] -> Maybe [String] +> processFields [room,fname,lname,gender,email1,email2,_,_,_,_,_,_] = +> let e1 = map toLower email1 +> e2 = map toLower email2 +> suffix = "@mit.edu" +> fix email = [room,fname,lname,gender,dropSuffix suffix email] +> in if suffix `isSuffixOf` e1 +> then Just $ fix e1 +> else if suffix `isSuffixOf` e2 +> then Just $ fix e2 +> else Nothing Property changes on: sandbox/trunk/src/one-off-scripts/ashdown-residents/res2.lhs ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-03 15:13:58
|
Revision: 1616 http://assorted.svn.sourceforge.net/assorted/?rev=1616&view=rev Author: yangzhang Date: 2010-04-03 15:13:52 +0000 (Sat, 03 Apr 2010) Log Message: ----------- added cp-p Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2010-04-02 13:50:14 UTC (rev 1615) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2010-04-03 15:13:52 UTC (rev 1616) @@ -714,6 +714,25 @@ sudo su - -c "toast $(quote "$@")" } +# From <http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/> +cp-p() { + strace -q -ewrite cp -- "${1}" "${2}" 2>&1 | + awk '{ + count += $NF + if (count % 10 == 0) { + percent = count / total_size * 100 + printf "%3d%% [", percent + for (i=0;i<=percent;i++) + printf "=" + printf ">" + for (i=percent;i<100;i++) + printf " " + printf "]\r" + } + } + END { print "" }' total_size=$(stat -c '%s' "${1}") count=0 +} + #function set_title() { # if [ $# -eq 0 ] ; then # eval set -- "$PWD" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-02 13:50:20
|
Revision: 1615 http://assorted.svn.sourceforge.net/assorted/?rev=1615&view=rev Author: yangzhang Date: 2010-04-02 13:50:14 +0000 (Fri, 02 Apr 2010) Log Message: ----------- added ocaml Added Paths: ----------- sandbox/trunk/src/ocaml/ sandbox/trunk/src/ocaml/dabble.ml Added: sandbox/trunk/src/ocaml/dabble.ml =================================================================== --- sandbox/trunk/src/ocaml/dabble.ml (rev 0) +++ sandbox/trunk/src/ocaml/dabble.ml 2010-04-02 13:50:14 UTC (rev 1615) @@ -0,0 +1,216 @@ +(* just generally playing around with ocaml *) + +(* modules *) + +module Hello : +sig + val hello : unit -> unit +end = +struct + let message = "Hello" + let hello () = print_endline message +end + +module type Hello2_type = +sig + val hello : unit -> unit +end +module Hello2 = +struct + let message = "Hello2" + let hello () = print_endline message +end + +let goodbye () = print_endline "Goodbye" +let hello_goodbye () = + Hello.hello (); + goodbye (); +;; + +(* objects *) + +open List + +class ['a] stack = +object (self) + val mutable the_list = ( [] : 'a list ) (* instance variable *) + method push x = (* push method *) + the_list <- x :: the_list + method pop = (* pop method *) + let result = hd the_list in + the_list <- tl the_list; + result + method peek = (* peek method *) + hd the_list + method size = (* size method *) + length the_list +end;; + +let drain_duck s = + while s#size > 0 do + ignore (s#pop) + done +;; + +let drain_stack (s : 'a stack) = + while s#size > 0 do + ignore (s#pop) + done +;; + +let test_stack () = + let s = new stack; + in + for i = 1 to 10 do + s#push i + done; + while s#size > 5 do + Printf.printf "Popped %d off the stack.\n" s#pop + done; + print_endline "Draining stack..."; + drain_duck s; + Printf.printf "%d remaining items on the stack.\n" s#size +;; + +(* mutable state *) + +let mstate () = + let myref = ref 3 + in + myref := !myref + 5; + print_int !myref (* 8 *); + print_newline (); +;; + +(* custom data structures *) + +class obj = +object (self) + val mutable parents = ( [] : obj list ) + method get_prop = + 0 + method set_prop = + 0 +end;; + +type (* set_v = { theset : string } +and str_v = { thestr : string } +(* +TODO add more here: +- cyclic type references +- cyclic references +- advanced data structures +- mutable objs; make sure you can control equality/hashing esp for objects +*) +and obj = { thename : string } +and *) value = StrV of string | SetV of string | Obj of obj +;; + +type (* set_t = { thetype : typ } +and *) obj_t = { theobj : obj } +and typ = StrT | SetT of typ | ObjT of obj +;; + +let types () = + let rec mytyp1 = SetT StrT + and o2 = new obj (* { thename = "hello" } *) + and o3 = new obj (* { thename = "hello" } *) + and mytyp2 = SetT(ObjT(o2)) + and mytyp3 = SetT(ObjT(o3)) + in + print_endline (string_of_bool (mytyp1 == mytyp2)); + print_endline (string_of_bool (mytyp2 == mytyp3)); +;; + +(* data structures: sets, maps *) + +(* module Obj_set = Set.Make + (struct + type t = obj + let compare = compare + end) +;; *) + +module Obj_map = Map.Make + (struct + type t = int + let compare = compare + end) +;; + +module SS = Set.Make(String);; + +(* module Obj_set = HashSet.Make(String) +type Obj_set = HashSet *) + +let test_ds () = + let s = SS.empty + and h = Hashtbl.create 100 in + SS.add "foobar"; +(* print_endline SS. *) +;; + +(* my objects *) + +class obj2 = +object (self) + val mutable parents = HashSet.create 100 "" + val mutable props = (Hashtbl.create 100 : (string, string) Hashtbl.t) + method get_prop p = Hashtbl.find props p +(* method set_prop p v = Hashtbl.find props p *) + method add_par par = HashSet.add parents par + method get_pars = HashSet.keys parents +end;; + +(* return values *) + +(* this actually returns 42, not () as you might think due to the ; *) +let foo () = + 42; +;; + +(* persistence *) + +open Marshal + +let marshal_list () = + let x = to_string [ "foo"; "bar" ] [] in + let y = (from_string x 0 : string list) in + print_endline (nth y 0); + print_endline (nth y 1); +;; + +let marshal_obj () = + let o = new obj2 in + let t = Hashtbl.create 100 in + let s = HashSet.create 100 "" in + o#add_par "one parent"; + Hashtbl.add t "adf" "zxcv"; + HashSet.add s "blah"; + let tser = to_string t [] in + let sser = to_string s [] in + let oser = to_string o [] in + let t2 = (from_string tser 0 : (string,string) Hashtbl.t) in + let s2 = (from_string sser 0 : string HashSet.t) in +(* let o2 = (from_string oser 0 : obj2) in*) + print_endline (Hashtbl.find t2 "adf"); + print_endline (Array.get (HashSet.keys s2) 0); +(* print_endline (Array.get (o2#get_pars) 0);*) +;; + +let main () = + hello_goodbye (); + mstate (); + types (); + print_int (foo ()); + print_newline (); + test_stack (); + test_ds (); + marshal_obj (); + marshal_list (); +;; + +main ();; + +(* match e with + Plus *) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-02 03:13:30
|
Revision: 1614 http://assorted.svn.sourceforge.net/assorted/?rev=1614&view=rev Author: yangzhang Date: 2010-04-02 03:13:23 +0000 (Fri, 02 Apr 2010) Log Message: ----------- added craigslist surveyor Added Paths: ----------- sandbox/trunk/src/one-off-scripts/craigslist-surveyor/ sandbox/trunk/src/one-off-scripts/craigslist-surveyor/main.bash sandbox/trunk/src/one-off-scripts/craigslist-surveyor/process.py Added: sandbox/trunk/src/one-off-scripts/craigslist-surveyor/main.bash =================================================================== --- sandbox/trunk/src/one-off-scripts/craigslist-surveyor/main.bash (rev 0) +++ sandbox/trunk/src/one-off-scripts/craigslist-surveyor/main.bash 2010-04-02 03:13:23 UTC (rev 1614) @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +for i in "" 100 200 300 400 500 600 700 800 900 1000 +do wget "http://sfbay.craigslist.org/pen/apa/index$i.html" +done + +cat index*.html | ./process.py Property changes on: sandbox/trunk/src/one-off-scripts/craigslist-surveyor/main.bash ___________________________________________________________________ Added: svn:executable + * Added: sandbox/trunk/src/one-off-scripts/craigslist-surveyor/process.py =================================================================== --- sandbox/trunk/src/one-off-scripts/craigslist-surveyor/process.py (rev 0) +++ sandbox/trunk/src/one-off-scripts/craigslist-surveyor/process.py 2010-04-02 03:13:23 UTC (rev 1614) @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import re, sys + +def simplify(s): return re.sub(r' +', '', s).lower() + +def mean(xs): return int(sum(xs))/len(xs) + +d = {} +for line in sys.stdin: + m = re.search(r'\$(\d+) \/ (\d+)br - .+> \(([^\)]+)\)<', line) + if m: + price, rooms, loc = m.groups() + price = int(price) + rooms = int(rooms) + loc = simplify(loc) + if rooms == 1 and price < 10000: + d.setdefault(loc, []).append(price) + +print d +for k in d: d[k] = mean(d[k]) +print '\n'.join(map(lambda (a,b): '%s\t%s'%(a,b), sorted((b,a) for a,b in d.iteritems()))) Property changes on: sandbox/trunk/src/one-off-scripts/craigslist-surveyor/process.py ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 19:08:29
|
Revision: 1612 http://assorted.svn.sourceforge.net/assorted/?rev=1612&view=rev Author: yangzhang Date: 2010-04-01 18:56:43 +0000 (Thu, 01 Apr 2010) Log Message: ----------- tweak Modified Paths: -------------- personal-site/trunk/README Modified: personal-site/trunk/README =================================================================== --- personal-site/trunk/README 2010-04-01 18:44:21 UTC (rev 1611) +++ personal-site/trunk/README 2010-04-01 18:56:43 UTC (rev 1612) @@ -1,2 +1,3 @@ +out: staging area for `make publish` static: images, css files, and other files that are directly copied into the published directory src: the source files that generate files to be published This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:57:22
|
Revision: 1613 http://assorted.svn.sourceforge.net/assorted/?rev=1613&view=rev Author: yangzhang Date: 2010-04-01 18:57:12 +0000 (Thu, 01 Apr 2010) Log Message: ----------- - removed dark style - removed links and recommendations pages - updated primary URL to yz.mit.edu (for redirection) - updated Google Analytics tracker code - removed other analytics systems - use async Google Analytics - removed extraneous email-munging code - removed old self-photos - merged in links - updated projects listing - removed valid XHTML/CSS links - cleaned up a bunch of old commented content (refs to ambitious zdb) - plain.css tweaks Modified Paths: -------------- personal-site/trunk/Makefile personal-site/trunk/src/footer.html personal-site/trunk/src/header.html personal-site/trunk/src/index.txt personal-site/trunk/src/redir-header.html personal-site/trunk/src/redir.txt personal-site/trunk/static/plain.css Removed Paths: ------------- personal-site/trunk/src/dark-epilogue.html personal-site/trunk/src/dark-prologue.html personal-site/trunk/src/dark.css personal-site/trunk/src/links.txt personal-site/trunk/src/recommendations.txt personal-site/trunk/static/me-shadow.png personal-site/trunk/static/me-shadow.xcf personal-site/trunk/static/me.jpg Modified: personal-site/trunk/Makefile =================================================================== --- personal-site/trunk/Makefile 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/Makefile 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,10 +1,9 @@ MUNGEMAIL := sed 's/><body$$/><body onload="javascript:body_onload();"/' PLAIN := out/plain.html -DARK := out/dark.html INDEX := out/index.html REDIR := out-redir/index.html -all: $(INDEX) $(PLAIN) $(DARK) $(REDIR) out/dark.css +all: $(INDEX) $(PLAIN) $(REDIR) svn export --force static out out: @@ -13,40 +12,29 @@ out-redir: mkdir -p out-redir -$(REDIR): src/redir.txt out-redir - pandoc -s -S --tab-stop=2 -c http://www.mit.edu/~y_z/plain.css \ +$(REDIR): src/redir.txt src/redir-header.html out-redir + pandoc -s -S --tab-stop=2 -c http://yz.mit.edu/plain.css \ -H src/redir-header.html src/redir.txt -o $(REDIR) -out/dark.css: src/dark.css - cpp -P -CC -traditional-cpp $^ $@ - -$(INDEX): $(DARK) +$(INDEX): $(PLAIN) ln -sf plain.html $(INDEX) -$(PLAIN): src/index.txt src/header.html out src/footer.html src/recommendations.txt src/links.txt +$(PLAIN): src/index.txt src/header.html out src/footer.html pandoc -s -S --tab-stop=2 -H src/header.html -A src/footer.html src/index.txt \ -c plain.css | \ $(MUNGEMAIL) > $(PLAIN) - pandoc -s -S --tab-stop=2 -H src/header.html -A src/footer.html src/recommendations.txt \ - -c plain.css -o out/recommendations.html - pandoc -s -S --tab-stop=2 -H src/header.html -A src/footer.html src/links.txt \ - -c plain.css -o out/links.html -$(DARK): src/index.txt src/header.html src/dark-prologue.html src/dark-epilogue.html out - pandoc -s -S --tab-stop=2 -H src/header.html src/index.txt \ - -c dark.css -B src/dark-prologue.html -A src/dark-epilogue.html | \ - $(MUNGEMAIL) > $(DARK) - publish: all - scp -o CompressionLevel=9 -r out/* lin:www/ + scp -o CompressionLevel=9 -r out/* lin:web_scripts/ publish-redir: $(REDIR) scp $(REDIR) cs:public_html/ scp $(REDIR) ocf:public_html/ scp $(REDIR) pdos:public_html/ - scp $(REDIR) lin:web_scripts/ + scp $(REDIR) lin:www/ scp $(REDIR) nms:public_html/ scp $(REDIR) hv:public_html/ + scp $(REDIR) zs:public_html/ clean: rm -rf out Deleted: personal-site/trunk/src/dark-epilogue.html =================================================================== --- personal-site/trunk/src/dark-epilogue.html 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/dark-epilogue.html 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,2 +0,0 @@ - </div> -</div> Deleted: personal-site/trunk/src/dark-prologue.html =================================================================== --- personal-site/trunk/src/dark-prologue.html 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/dark-prologue.html 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,9 +0,0 @@ -<div class="main"> - <div class="title"><h1>yang zhang</h1></div> - <div class="menu"> - <a href="#about"><span>about</span></a> - <a href="#contact"><span>contact</span></a> - <a href="#projects"><span>projects</span></a> - <a href="#classes"><span>classes</span></a> - </div> - <div class="content"> Deleted: personal-site/trunk/src/dark.css =================================================================== --- personal-site/trunk/src/dark.css 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/dark.css 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,170 +0,0 @@ -/* - * This is loosely based on the 'Blackbox' theme by Viktor Persson - * (http://arcsin.se/). - */ - -#define DIM_GOLD #805D08 /* #B8860B */ -#define BRIGHT_GOLD #DAA520 - -#define DIM_BLUE #87BEEB -#define BRIGHT_BLUE #D0EFFF - -#define TEXT_GRAY #DDDDDD -#define TEXT_WHITE #DDDDDD -#define H1_COLOR #DDDDDD -#define H2_COLOR #FFFFFF -#define LINK DIM_BLUE -#define LINK_HOVER BRIGHT_BLUE -#define MENU_BORDER DIM_ORANGE -#define MENU_HOVER DIM_ORANGE - -/* Standard elements */ -/* -* { - margin: 0; - padding: 0; -} - */ - -a { - color: DIM_BLUE; - text-decoration: none; -} - -a:hover { - color: BRIGHT_BLUE; -} - -body { - background: black url(img/bg.png) repeat-x fixed left bottom; - color: TEXT_WHITE; - margin: 20px 0; - text-align: center; - font: normal 0.8em sans-serif,Arial; -} - -ul { - /* for MSIE */ - margin-left: 1.5em; - padding-left: 0em; -} - -li { - /* list-style: url(img/li.gif); */ - /* margin-left: 18px; */ -} - -code { - font: normal 1em "Lucida Sans Unicode",serif; - background: url(img/bgcode.gif); - color: #888; - display: block; - padding: 3px 6px; - white-space: pre; - margin-bottom: 12px; -} - -/* Misc */ -div.quote { - margin-bottom: 12px; - font: normal 1.1em "Lucida Sans Unicode",serif; - background: url(img/quote.gif) no-repeat; - padding-left: 28px; - color: gray; -} - - -/* Main structure */ -.main { - background: #000; - border: 3px double #EEE; - border-color: DIM_GOLD; /* #222; /* #141414 #202020 #222 #202020; */ - margin: 20px auto 4px auto; - text-align: left; - width: 600px; -} - -/* Header */ -.title { - float: left; - width: 190px; - height: 30px; -} -.title h1 { - color: TEXT_GRAY; - font: normal 1.5em sans-serif; - letter-spacing: 0.2em; - padding-left: 10px; - /* padding-bottom: -10px; */ - /* margin-top: 30px; */ - /* padding: 16px 20px; */ - text-transform: lowercase; -} - - -/* Menu */ -div.menu { - float: right; -} -.menu a { - background: #000; /* url(img/bgmenu.png) repeat-x; */ - /* - border-left: 1px solid #222; - border-right: 1px solid #222; - border-top: 1px solid #222; - */ - color: DIM_GOLD; /* #7799bb; */ - float: left; - padding-top: 4px; - width: 100px; height: 30px; - border-top: 3px solid black; -} -.menu a span { - padding-left: 6px; -} -.menu a:hover { - background-position: left bottom; - color: BRIGHT_GOLD; - border-top: 3px solid BRIGHT_GOLD; -} - - -/* Content */ -.content { - /* border-top: 1px solid DIM_GOLD; */ - background: black; - clear: both; - padding: 8px 10px; -} -.content h1, img { - display: none; -} -.content h2 { - /* margin: 0 0 4px; */ - text-transform: lowercase; - border-top: 1px solid DIM_GOLD; - font: 1.3em sans-serif; - font-weight: normal; - margin-right: -10px; - color: H2_COLOR; -} -.content p { - /* margin: 0 0 12px; */ -} - -/* Footer */ -.footer { - padding: 5px; - background: #0A0A0A; - color: #666; -} -/* TODO fix the spacing -.footer p { - padding-top: -10px; - padding-bottom: -10px; -} -*/ - -/* - * vim:noet:sw=4:ts=4 - */ Modified: personal-site/trunk/src/footer.html =================================================================== --- personal-site/trunk/src/footer.html 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/footer.html 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,10 +1,3 @@ -<!-- Footer links --> -<div class="footer"> - <!--<p>Styles: <a href="plain.html">Plain</a> | <a href="dark.html">Dark</a></p>--> - <p>Valid XHTML 1.0 (<a href="http://validator.w3.org/check/referer">re-validate</a>)</p> - <p>Valid CSS (<a href="http://jigsaw.w3.org/css-validator/check/referer">re-validate</a>)</p> -</div> - <!-- Project Honeypot --> <div id="spamlink" style="position: absolute; top: -250px; left: -250px;"> <a href="http://people.csail.mit.edu/yang/appraisal.php">pattern</a> @@ -12,23 +5,3 @@ <!-- <style>a.pudris{color:#FFF;font:bold 10px arial,sans-serif;text-decoration:none;}</style><table cellspacing="0"cellpadding="0"border="0"style="background:#999;width:230px;"><tr><td valign="top"style="padding: 1px 2px 5px 4px;border-right:solid 1px #CCC;"><span style="font:bold 30px arial,sans-serif;color:#666;top:0px;position:relative;">@</span></td><td valign="top" align="left" style="padding:3px 0 0 4px;"><a href="http://www.projecthoneypot.org/" class="pudris">MEMBER OF PROJECT HONEY POT</a><br/><a href="http://www.unspam.com"class="pudris">Spam Harvester Protection Network<br/>provided by Unspam</a></td></tr></table> --> - -<!-- Google Analytics --> -<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"/> -<script type="text/javascript"> - _uacct = "UA-1322324-1"; - urchinTracker(); -</script> - -<!-- Performance Metrics --> -<script src="http://pmetrics.performancing.com/102.js" type="text/javascript"></script> -<noscript><p><img alt="Performancing Metrics" src="http://pmetrics.performancing.com/102ns.gif" /></p></noscript> - -<!-- Quantcast --> -<script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script> -<script type="text/javascript"> - _qacct="p-45nKPbm9DJOeE";quantserve(); -</script> -<noscript> - <img src="http://pixel.quantserve.com/pixel/p-45nKPbm9DJOeE.gif" style="display: none" height="1" width="1" alt="Quantcast"/> -</noscript> Modified: personal-site/trunk/src/header.html =================================================================== --- personal-site/trunk/src/header.html 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/header.html 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,13 +1,10 @@ <meta name="no-email-collection" content="http://www.unspam.com/noemailcollection" /> <meta name="verify-v1" content="d8peXpEYa9lz6TBtLim5WB9X0DP40G5qmNZENCT3rGA=" /> <meta name="verify-v1" content="xcIyp637+f42aznWePbI2c0qUCVoqQhIDIoKCsQV9fM=" /> - <style type="text/css"> - .footer { - font-size: smaller - } - </style> + <script type="text/javascript"> // <![CDATA[ + function link( prot, name, domain ) { addr = name; if ( domain ) { @@ -20,28 +17,25 @@ } return html; } - var ul = document.createElement( 'ul' ); - function item( label, arg1, arg2, arg3 ) { - if ( arg3 ) { - html = label + ': ' + link( arg1, arg3, arg2 ); - } else if ( arg2 ) { - html = label + ': ' + link( arg1, arg2 ); - } else { - html = label + ': ' + arg1; - } - var li = document.createElement( 'li' ); - li.innerHTML = html; - ul.appendChild( li ); - } - function writeItems() { - document.getElementById( 'items' ).appendChild( ul ); - } - function hideSpamLink() { + function body_onload() { + // create email link + document.getElementById( 'email' ).innerHTML = + link( 'mailto:', 'yaaang', 'gmail.com' ); + // hide spam link document.getElementById( 'spamlink' ).style.visibility = 'hidden'; } - function body_onload() { - writeItems(); - hideSpamLink(); - } + + // Google Analytics --> + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-1561381-1']); + _gaq.push(['_trackPageview']); + (function() { + var ga = document.createElement('script'); + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : + 'http://www') + '.google-analytics.com/ga.js'; + ga.setAttribute('async', 'true'); + document.documentElement.firstChild.appendChild(ga); + })(); + // ]]> </script> Modified: personal-site/trunk/src/index.txt =================================================================== --- personal-site/trunk/src/index.txt 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/index.txt 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,13 +1,22 @@ % Yang Zhang % Yang Zhang -<img src="me-shadow.png" alt="Tim the Beaver and me" style="border: 5px solid; border-color: white; float: right;"/> +<div style="font-weight: bold"> + <span id="email"></span> | [Google (Buzz) Profile] | [Blog] +</div> +[Google (Buzz) Profile]: http://www.google.com/profiles/yaaang/ +[Blog]: http://yz.mit.edu/wp/ + <a name="about"></a> About me -------- +<img src="http://www.gravatar.com/avatar/e17a97a879e919ebc943bfb9d3fec409.png" + alt="Tim the Beaver and me" + style="box-shadow: 3px 3px 10px black; -webkit-box-shadow: 3px 3px 10px black; float: right;"/> + I'm a graduate student working with Prof. [Sam Madden] in [CSAIL] at [MIT]. I graduated from [UC Berkeley] in 2005 with a BS in Electrical Engineering and Computer Science. @@ -17,37 +26,28 @@ [MIT]: http://mit.edu/ [UC Berkeley]: http://berkeley.edu/ -<a name="contact"></a> +- [Google (Buzz) profile]: includes my Google Reader shared items---probably my + most popular web property---as well as my blog entries, bookmarks, and tweets +- [Blog] +- [Delicious Bookmarks]: Mirrors my Google Bookmarks using + [gbookmark2delicious]. I post articles, software, projects, services, + homepages, and anything else + of non-transient noteworthiness that I come across. +- [Notes Wiki]: My pile of notes, mostly on computer science. +- [Twitter](http://www.twitter.com/yaaang) +- [Facebook](http://www.facebook.com/yaaang) +- [LinkedIn](http://www.linkedin.com/in/yzhang) +- [GitHub](http://github.com/yang/) +- [GPG Key] ([MIT PKS entry]) -Contact information -------------------- +[Google (Buzz) profile]: http://www.google.com/profiles/yaaang +[Blog]: http://y_z.scripts.mit.edu/wp/ +[Notes Wiki]: http://zs.ath.cx:5001/ +[Delicious Bookmarks]: http://del.icio.us/yaaang/ +[gbookmark2delicious]: http://gbookmark2delicious.googlecode.com/ +[GPG Key]: yang.gpg.asc +[MIT PKS entry]: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xB1E65B60 -<div> - <noscript> - <p> - <em> - Contact info obfuscated using JavaScript. Please enable JavaScript for correct rendering. - </em> - </p> - </noscript> - <div id="items"></div> - <script type="text/javascript"> - // <![CDATA[ - document.write( '<ul>' ); - item( 'Email', 'mailto:', 'mit.edu', 'y_z' ); - //item( 'AIM', 'aim:goim?screenname=', 'sorta lame' ); - //item( 'MSN', null, 'hotmail.com', 'noneofthegoodnameswereleft' ); - //item( 'Yahoo', 'ymsgr:sendIM?', 'overbored' ); - item( 'Jabber (Google)', 'xmpp:', 'gmail.com', 'yaaang' ); - //item( 'Skype', 'callto://', 'yaaang' ); - //item( 'FreeNode', 'irc://irc.freenode.org/', 'zeeee' ); - item( '"Office"', 'MIT/CSAIL <a href="http://whereis.mit.edu/map-jpg?selection=32&Buildings=go">32</a>-<a href="http://www.csail.mit.edu/resources/maps/9G/G908.gif">G908</a>, <a href="http://www.eecs.mit.edu/stata-link.html">Stata Center</a>, <a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q=32+Vassar+St,+Cambridge,+MA+02139&sll=42.357926,-71.093616&sspn=0.00842,0.01575&ie=UTF8&ll=42.362682,-71.093495&spn=0.008419,0.01575&z=16&iwloc=addr">32 Vassar St., Cambridge, MA 02139</a>' ); - item( 'GPG public key', '<a href="yang.gpg.asc">yang.gpg.asc</a> (<a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xB1E65B60">MIT PKS entry</a>)' ); - document.write( '</ul>' ); - // ]]> - </script> -</div> - <a name="projects"></a> Projects @@ -56,9 +56,11 @@ Here are the (non-confidential) projects in which I've been involved. More details when I have time! +- Hedwig: a topic-based publish-subscribe wide-area messaging system designed + as a replication service in distributed systems like Yahoo [PNUTS] - [H-Store]: a distributed main-memory relational database management system for on-line transaction processing workloads. -- Invirt: [SIPB]'s virtual machine management system. The name of the MIT +- [Invirt]: [SIPB]'s virtual machine management system. The name of the MIT instance of this service is [XVM]. - [Corey]: an exokernel operating system for many-core architectures. - [WebTables]: web-scale information retrieval over structured data. @@ -93,6 +95,8 @@ - [Recovery-Oriented Computing] (ROC). - [Microsoft Search] and [Microsoft SharePoint Portal Server]. +[PNUTS]: http://research.yahoo.com/project/212 +[Invirt]: http://invirt.mit.edu/ [SIPB]: http://sipb.mit.edu/ [XVM]: http://xvm.mit.edu/ [Corey]: http://pdos.csail.mit.edu/~sbw/corey/ @@ -100,14 +104,12 @@ [H-Store]: http://db.cs.yale.edu/hstore/ [WebTables]: slides/webtables-presentation-google07.pdf -[Scalable Resilient Overlay Networks]: http://nms.csail.mit.edu/ron/ +[Scalable Resilient Overlay Networks]: http://projects.csail.mit.edu/overlayrouting/ [CarTel]: http://cartel.csail.mit.edu/ [Intermittently Connected Embedded Database]: http://cartel.csail.mit.edu/icedb/ [CafNet]: http://cartel.csail.mit.edu/cafnet/ -<!-- TODO: mirror this pdf --> - [Guarded Atomic Actions for Haskell]: papers/gaah.pdf [TelegraphCQ]: http://telegraph.cs.berkeley.edu/ @@ -125,13 +127,11 @@ Misc Software ------------- -<!-- TODO: ZDB provides comprehensive navigable views of your software/projects ---> - These are various other software I've worked on, not exclusively associated with any particular project above. - [Assorted Projects]: my code dump---find a bunch more programs here +- [SRON]: scalable resilient overlay system - [gbookmark2delicious]: Python script to migrate/sync Google Bookmarks to del.icio.us - [JSamp]: a simple sampling profiler for Java @@ -148,6 +148,7 @@ [ICFPC 2007 entry]: http://downloads.sourceforge.net/assorted/icfpc2007-lazybottoms.tgz [JSamp]: http://jsamp.googlecode.com/ [Simple Publications Manager]: http://pubmgr.sf.net/ +[SRON]: http://projects.csail.mit.edu/overlayrouting/ [gbookmark2delicious]: http://gbookmark2delicious.googlecode.com/ <a name="papers"></a> @@ -155,7 +156,9 @@ Papers ------ -<!-- TODO: mirror papers. integrate with zdb --> +- David Sontag (MIT), Yang Zhang (MIT), Amar Phanishayee (CMU), David Andersen + (CMU), David Karger (MIT). _Scaling all-pairs overlay routing to the + thousands_. CoNEXT 2009. - Silas Boyd-Wickizer (MIT), Haibo Chen (Fudan University), Rong Chen (Fudan University), Yandong Mao (Fudan University), Frans Kaashoek (MIT), Robert @@ -186,18 +189,6 @@ Distributed Mobile Sensor Computing System_. Sensys 2006. [PDF](http://portal.acm.org/ft_gateway.cfm?id=1182821&type=pdf&coll=GUIDE&dl=GUIDE&CFID=53267823&CFTOKEN=16451677) -<!-- TODO: * means that the authors contributed equally to the project. --> - -<!-- -Co-Authors -========== - -- Alon Halevy -- Dave Andersen -- Hari Balakrishnan -- Sam Madden ---> - <a name="classes"></a> MIT classes @@ -215,40 +206,6 @@ - 6.033 Computer Systems Engineering (TA, spring 2007) - 6.00 Introduction to Computer Science (TA, fall 2008) -<a name="stuff"></a> - -Stuff ------ - -- [My blog](http://y_z.scripts.mit.edu/wp/) -- [Links](links.html) -- [Software recommendations](recommendations.html) -<!-- - [Notes](notes/) --> - -<!-- Extreme Tracking --> -<div id="eXTReMe"><a href="http://extremetracking.com/open?login=yzzororg"> -<img src="http://t1.extreme-dm.com/i.gif" style="border: 0;" -height="38" width="41" id="EXim" alt="eXTReMe Tracker" /></a> -<script type="text/javascript"><!-- -var EXlogin='yzzororg' // Login -var EXvsrv='s9' // VServer -EXs=screen;EXw=EXs.width;navigator.appName!="Netscape"? -EXb=EXs.colorDepth:EXb=EXs.pixelDepth; -navigator.javaEnabled()==1?EXjv="y":EXjv="n"; -EXd=document;EXw?"":EXw="na";EXb?"":EXb="na"; -EXd.write("<img src=http://e0.extreme-dm.com", -"/"+EXvsrv+".g?login="+EXlogin+"&", -"jv="+EXjv+"&j=y&srw="+EXw+"&srb="+EXb+"&", -"l="+escape(EXd.referrer)+" height=1 width=1>");//--> -</script><noscript><div id="neXTReMe"><img height="1" width="1" alt="" -src="http://e0.extreme-dm.com/s9.g?login=yzzororg&j=n&jv=n" /> -</div></noscript></div> -<script type="text/javascript"> -var img = document.getElementById("EXim"); -img.width=1; -img.height=1; -</script> - <!-- vim:ft=mkd:et:sw=2:ts=2:nocin --> Deleted: personal-site/trunk/src/links.txt =================================================================== --- personal-site/trunk/src/links.txt 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/links.txt 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,114 +0,0 @@ -% Links -% Yang Zhang - -Myself Elsewhere ----------------- - -- [My blog] -- [Bookmarks]: Mirrors my Google Bookmarks using [gbookmark2delicious]. I post - articles, software/tools, research projects, homepages, and just about - anything else noteworthy that I come across. -- [Google Reader Shared Items]: These are articles that I found interesting - from my RSS reader (Google Reader). I try to keep this restricted to posts - that are technical in nature, with a heavy emphasis on software systems in - computer science, but sometimes I share things like release announcements of - some of my favorite software. -- [All my feed subscriptions] ([RSS]): All my Google Reader subscriptions, - merged via Yahoo Pipes. Like my shared items, this is still mostly technical - content. -- [Facebook profile](http://www.facebook.com/profile.php?id=708869) -- [LinkedIn profile](http://www.linkedin.com/in/yzhang) -- [Google profile](http://www.google.com/profiles/yaaang) - -[My blog]: http://y_z.scripts.mit.edu/wp/ -[Bookmarks]: http://del.icio.us/yaaang/ -[gbookmark2delicious]: http://gbookmark2delicious.googlecode.com/ -[Google Reader Shared Items]: https://www.google.com/reader/shared/18352898346631652002 -[All my feed subscriptions]: http://pipes.yahoo.com/pipes/pipe.info?_id=0tn5f2MV3RGk8DsIYEsBXw -[RSS]: http://pipes.yahoo.com/pipes/pipe.run?_id=0tn5f2MV3RGk8DsIYEsBXw&_render=rss - -Selected Blogroll ------------------ - -- [All Things Distributed]: Werner Vogels' blog (Amazon CTO and former CMU - prof). Focus on distributed systems and AWS. Low frequency. -- [Ars Technica]: Jon "Hannibal" Stokes' great explanatory articles on computer - architecture topics. Low frequency. -- [Evan Jones' Scratch Pad]: Labmate's blog on systems topics with occasional - low-level articles on programming. Low frequency. -- [Geeking with Greg]: A blog by Greg Linden, the guy behind Amazon's - recommendation and personalization systems, now at MS Live Labs. Lots of good - discussion on IR and related research. Low frequency. -- [Haskell Weekly News]: Briefs about updates in the wonderful world of - Haskell. -- [High Scalability]: Blog on systems and scalability, particularly in the web - applications/datacenter universe. High noise, but sometimes useful notes are - posted. Medium frequency. -- [Lambda The Ultimate]: A discussion forum on programming languages, with a - heavy emphasis on "PL design." Medium frequency. -- [Linux Weekly News]: Jonathan Corbet writes good explanatory articles in the - Weekly Edition. -- [Paper Trail]: Explanatory summaries on distributed systems research, old and - new. Low frequency. -- [Papers in Computer Science]: Superb summaries and discussion on seminal - papers across all of CS. Medium frequency. -- [Saturday Morning Breakfast Cereal]: Sick strip. -- [The Monad Reader]: The Haskell magazine. "It is less formal than journal, - but somehow more enduring than a wiki-page." An issue every few months. -- [research!rsc]: Labmate Russ Cox's blog. Focus on history of computing. Low - frequency. - -[All Things Distributed]: http://www.allthingsdistributed.com/ -[Ars Technica]: http://arstechnica.com/index.ars -[Evan Jones' Scratch Pad]: http://evanjones.ca/ -[Geeking with Greg]: http://glinden.blogspot.com/ -[Haskell Weekly News]: http://sequence.complete.org/hwn/ -[High Scalability]: http://www.highscalability.com/ -[Kernel Trap]: http://kerneltrap.org/ -[Lambda The Ultimate]: http://www.lambda-the-ultimate.org/ -[Linux Weekly News]: http://www.lwn.net/ -[Paper Trail]: http://hnr.dnsalias.net/wordpress/ -[Papers in Computer Science]: http://papersincomputerscience.org/ -[Saturday Morning Breakfast Cereal]: http://www.smbc-comics.com/ -[The Monad Reader]: http://www.haskell.org/haskellwiki/The_Monad.Reader -[research!rsc]: http://research.swtch.com/ - -Conferences ------------ - -- Systems - - [ASPLOS](http://www.acm.org/pubs/contents/proceedings/series/asplos/) - - [OSDI](http://www.usenix.org/event/byname/osdi.html) - - [SOSP](http://www.sosp.org/) - - [USENIX](http://www.usenix.org/event/byname/usenix.html) -- Databases - - [SIGMOD](http://www.sigmod.org/) - - [VLDB](http://www.vldb.org/) -- Networking - - [SIGCOMM](http://www.sigcomm.org/) - - [NSDI](http://www.usenix.org/event/byname/nsdi.html) -- Programming languages - - [ICFP](http://www.icfpconference.org/) - - [OOPSLA](http://www.oopsla.org/) - - [PLDI](http://www.sigplan.org/pldi.htm) - - [POPL](http://www.sigplan.org/popl.htm) -- Graphics - - [SIGGRAPH](http://www.siggraph.org/) - -Frequently Visited ------------------- - -- [Campusfood](http://campusfood.com/) -- [Facebook](http://facebook.com/) -- [Google Calendar](http://calendar.google.com/) -- [Google Reader](http://reader.google.com/) -- [Remember the Milk](http://rememberthemilk.com/) - -Podcasts and Videos -------------------- - -- [Going Deep](http://channel9.msdn.com/shows/Going_Deep) -- [Google Channel on Youtube](http://www.youtube.com/user/Google) -- [MSR Videos on - ResearchChannel](http://www.researchchannel.org/prog/displayinst.aspx?fID=880) -- [Software Engineering Radio](http://se-radio.net/) Deleted: personal-site/trunk/src/recommendations.txt =================================================================== --- personal-site/trunk/src/recommendations.txt 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/recommendations.txt 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,102 +0,0 @@ -% Software Recommendations -% Yang Zhang - -Underdogs ---------- - -Some underdogs that more people should know about. - -- __[toast]__: Automated software retrieval, compilation, installation, and - removal with safe compartmentalization and non-root usage. Works without - hassle 90% of the time. Supports a variety of package types, including - autotools, plain prefix-dir, plain make, [distutils], [Cabal], and more. - -[toast]: http://toastball.net/toast/ -[Cabal]: http://www.haskell.org/cabal/ -[distutils]: http://docs.python.org/lib/module-distutils.html - -- __[pandoc]__: [Markdown] done right. A sane markup (structured text) - language supporting a variety of input and output formats, including HTML, - man, and TeX. [AsciiDoc] is a close runner-up; [ReST] is more complex. - Pandoc includes support for both of these. Hopefully the future will yield - markup languages with greater extensibility and enough flexibility to be used - in everything from [wikis] to comment documentation. - -[AsciiDoc]: http://www.methods.co.nz/asciidoc/ -[Markdown]: http://daringfireball.net/projects/markdown/ -[ReST]: http://docutils.sourceforge.net/rst.html -[pandoc]: http://johnmacfarlane.net/pandoc/ -[wikis]: http://code.google.com/p/pandocwiki/ - -- __[rubber]__: A usable frontend for LaTeX and all its friends: BibTeX, image - converters, etc. Similar to but more modular than [latexmk]. - -[rubber]: http://www.pps.jussieu.fr/~beffara/soft/rubber/ -[latexmk]: http://www.phys.psu.edu/~collins/software/latexmk-jcc/ - -<!-- TODO ensure the following is formatted correctly. --> - -- __[Gobby]__: A collaborative text editor. Examples of things I've used it - for: - - peer programming - - whiteboard - - online meetings (everybody ends up communicating exclusively in the - document; you get meeting minutes for free!) - - Emacs has `make-frame-on-display`, but it's quirky (e.g. going to the - minibuffer locks up everything else). Vim also has a "collaborative editing" - as an item sponsors can vote on. [screen] can be a poor man's collaborative - editor (it's decent as a whiteboard, at least). - -[Gobby]: http://gobby.0x539.de/trac/ -[screen]: http://www.gnu.org/software/screen/ - -- __[gprof2dot]__: A handy tool for visualizing the callgraph results of gprof, - the Google CPU profiler, Python cProfile, and more. - -[gprof2dot]: http://code.google.com/p/jrfonseca/wiki/Gprof2Dot - -- __[wtf]__: A filter for `g++`'s obscure page-long template errors. Resulting - error messages are readable and beautified. See also [gstlfilt]. - -[wtf]: http://nmstl.sourceforge.net/doc/nmstl-guide.html -[gstlfilt]: http://www.bdsoft.com/tools/stlfilt.html - -- __[clamp]__: A C++ preprocessor that provides lambda. Boost ScopeExit - provides something similar but less general. - -[clamp]: http://home.clara.net/raoulgough/clamp/ - -- __[Lazy C++]__: A C++ preprocessor that allows you to (mostly) ignore - separation of headers and source files. - -[Lazy C++]: http://www.lazycplusplus.com/ - -- __[Scala]__: An awesome JVM language. Give this a look if you're working on - the JVM and have some freedom to choose your tools. - -[Scala]: http://www.scala-lang.org/ - -Preferred Applications ----------------------- - -- Web browser: [Opera]. The fastest, smallest browser I've used is also the - most usable and comes with the most features out of the box. [Chrome] is - making great strides on the Windows-only front, and [Firefox] has a ton of - useful extensions. - -[Opera]: http://www.opera.com/ -[Chrome]: http://www.google.com/chrome -[Firefox]: http://www.firefox.com/ - -- Mail: [Thunderbird]. Fast, usable, and generally "good enough" (sorry, - nothing astounding). I've tried various others, from Outlook to Horde to - Pine to Sup, and I think this one annoys me the least. I still prefer the - [Gmail] experience, but my main mailbox is on an IMAP server. - -[Thunderbird]: http://www.mozilla.com/en-US/thunderbird/ -[Gmail]: http://www.gmail.com/ - -<!-- -vim:ft=mkd:et:sw=2:ts=2:nocin ---> Modified: personal-site/trunk/src/redir-header.html =================================================================== --- personal-site/trunk/src/redir-header.html 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/redir-header.html 2010-04-01 18:57:12 UTC (rev 1613) @@ -1 +1 @@ -<meta http-equiv="refresh" content="1;url=http://www.mit.edu/~y_z/" /> +<meta http-equiv="refresh" content="1;url=http://yz.mit.edu/" /> Modified: personal-site/trunk/src/redir.txt =================================================================== --- personal-site/trunk/src/redir.txt 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/src/redir.txt 2010-04-01 18:57:12 UTC (rev 1613) @@ -1,4 +1,4 @@ % Yang Zhang % Yang Zhang -My homepage is currently at <http://www.mit.edu/~y_z/>. +My homepage is at <http://yz.mit.edu/>. Deleted: personal-site/trunk/static/me-shadow.png =================================================================== (Binary files differ) Deleted: personal-site/trunk/static/me-shadow.xcf =================================================================== (Binary files differ) Deleted: personal-site/trunk/static/me.jpg =================================================================== (Binary files differ) Modified: personal-site/trunk/static/plain.css =================================================================== --- personal-site/trunk/static/plain.css 2010-04-01 18:56:43 UTC (rev 1612) +++ personal-site/trunk/static/plain.css 2010-04-01 18:57:12 UTC (rev 1613) @@ -56,6 +56,7 @@ border-bottom: 2px solid silver; color: gray; letter-spacing: -2px; + font-size: 20pt; } h2 { border-bottom: 2px solid; @@ -298,3 +299,7 @@ /* IE6 sets dynamically generated links as visited. */ div#toc a:visited { color: blue; } + +.footer { + font-size: smaller +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:44:29
|
Revision: 1611 http://assorted.svn.sourceforge.net/assorted/?rev=1611&view=rev Author: yangzhang Date: 2010-04-01 18:44:21 +0000 (Thu, 01 Apr 2010) Log Message: ----------- updated tocdepth demo: initialize tocdepth and tried selectively counted subsubsections Modified Paths: -------------- sandbox/trunk/src/tex/tocdepth.tex Modified: sandbox/trunk/src/tex/tocdepth.tex =================================================================== --- sandbox/trunk/src/tex/tocdepth.tex 2010-04-01 18:41:26 UTC (rev 1610) +++ sandbox/trunk/src/tex/tocdepth.tex 2010-04-01 18:44:21 UTC (rev 1611) @@ -1,4 +1,12 @@ \documentclass{article} + +% doesn't actually matter where you set this +\setcounter{tocdepth}{3} + +% this doesn't work TODO +% use this for subsubsections that you *do* wish to have included +\newcommand\Subsubsection[1]{\subsubsection{#1}\addcontentsline{toc}{subsubsection}{#1}} + \begin{document} \tableofcontents \appendix @@ -7,11 +15,10 @@ \section{gamma} \subsection{alfa} \subsection{bravo} -\subsubsection{first} +\begingroup\def\addcontentsline#1#2#3\relax\subsubsection{FIRST}\endgroup \subsubsection{second} \subsubsection{third} \subsubsection{billionth} -\setcounter{tocdepth}{2} % doesn't matter where you set this; can't be "selective" \subsection{charlie} \subsubsection{first} \subsubsection{second} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:41:34
|
Revision: 1610 http://assorted.svn.sourceforge.net/assorted/?rev=1610&view=rev Author: yangzhang Date: 2010-04-01 18:41:26 +0000 (Thu, 01 Apr 2010) Log Message: ----------- demo of cmd line argument processing Added Paths: ----------- sandbox/trunk/src/win/cmdlineargs/ sandbox/trunk/src/win/cmdlineargs/Makefile sandbox/trunk/src/win/cmdlineargs/sink.cc Copied: sandbox/trunk/src/win/cmdlineargs/Makefile (from rev 1486, sandbox/trunk/src/win/mingw/Makefile) =================================================================== --- sandbox/trunk/src/win/cmdlineargs/Makefile (rev 0) +++ sandbox/trunk/src/win/cmdlineargs/Makefile 2010-04-01 18:41:26 UTC (rev 1610) @@ -0,0 +1,3 @@ +CC = i586-mingw32msvc-gcc +CXX = i586-mingw32msvc-g++ +all: sink Property changes on: sandbox/trunk/src/win/cmdlineargs/Makefile ___________________________________________________________________ Added: svn:mergeinfo + Copied: sandbox/trunk/src/win/cmdlineargs/sink.cc (from rev 1485, sandbox/trunk/src/win/mingw/hello.c) =================================================================== --- sandbox/trunk/src/win/cmdlineargs/sink.cc (rev 0) +++ sandbox/trunk/src/win/cmdlineargs/sink.cc 2010-04-01 18:41:26 UTC (rev 1610) @@ -0,0 +1,17 @@ +#define UNICODE +#include <windows.h> +#include <iostream> +using namespace std; +int main(int argc, wchar_t **argv) { +#if 0 + wchar_t str[] = L"hello, world!\n"; + DWORD count; + WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), + str, + sizeof str / sizeof(wchar_t), + &count, + NULL); +#endif + cout << "hello, world!" << endl; + return 0; +} Property changes on: sandbox/trunk/src/win/cmdlineargs/sink.cc ___________________________________________________________________ Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:39:52
|
Revision: 1609 http://assorted.svn.sourceforge.net/assorted/?rev=1609&view=rev Author: yangzhang Date: 2010-04-01 18:39:43 +0000 (Thu, 01 Apr 2010) Log Message: ----------- tweak array size Modified Paths: -------------- ydb/trunk/src/rectpcc.clamp.lzz Modified: ydb/trunk/src/rectpcc.clamp.lzz =================================================================== --- ydb/trunk/src/rectpcc.clamp.lzz 2010-04-01 18:39:14 UTC (rev 1608) +++ ydb/trunk/src/rectpcc.clamp.lzz 2010-04-01 18:39:43 UTC (rev 1609) @@ -51,7 +51,7 @@ // Deserialize. tpcc_recovery_header &hdr = *reinterpret_cast<tpcc_recovery_header*>(rawbuf); long long before_deser = current_time_millis(); - array<char> buf(rawbuf, hdr.len); + array<char> buf(rawbuf, arr.size()); g_tables->deser(0, 1, hdr, buf); buf.release(); long long after_deser = current_time_millis(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:39:23
|
Revision: 1608 http://assorted.svn.sourceforge.net/assorted/?rev=1608&view=rev Author: yangzhang Date: 2010-04-01 18:39:14 +0000 (Thu, 01 Apr 2010) Log Message: ----------- adjusted bar plots Modified Paths: -------------- ydb/trunk/tools/analysis.py Modified: ydb/trunk/tools/analysis.py =================================================================== --- ydb/trunk/tools/analysis.py 2010-04-01 18:37:16 UTC (rev 1607) +++ ydb/trunk/tools/analysis.py 2010-04-01 18:39:14 UTC (rev 1608) @@ -267,7 +267,7 @@ for g in d: bottom = 0 for yval, yerr, label in g: - bar(xs + space * i + (space - width) / 2., + bar(xs + space * i + space + (space - width) / 2., yval, yerr = yerr, width = width, color = hues.next(), edgecolor = (1,1,1), ecolor = ehues.next(), label = label, bottom = bottom) @@ -297,7 +297,7 @@ groupbar( res.values()[0]['config'], - # y-value y-error label + # y-value y-error label [ [ (a['prerec mean'], a['prerec sd'], 'before network recovery'), (a['durrec mean'], a['durrec sd'], 'during network recovery'), ], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:37:24
|
Revision: 1607 http://assorted.svn.sourceforge.net/assorted/?rev=1607&view=rev Author: yangzhang Date: 2010-04-01 18:37:16 +0000 (Thu, 01 Apr 2010) Log Message: ----------- added getphotos.js for photo album archival Added Paths: ----------- facebook-tools/trunk/src/getphotos.js Added: facebook-tools/trunk/src/getphotos.js =================================================================== --- facebook-tools/trunk/src/getphotos.js (rev 0) +++ facebook-tools/trunk/src/getphotos.js 2010-04-01 18:37:16 UTC (rev 1607) @@ -0,0 +1,19 @@ +include("fileio.js") +var doc = document +function get(x) { + return doc.getElementById(x); +} +function out(x) { + output(x) + append("/tmp/output", x + "\n") +} +while (true) { + var p = get("myphoto") + lastsrc = p.src + var pid = get("photo_count").textContent.split(" ") + out(pid[1] + "/" + pid[3] + " " + p.src) + click(find("Next")) + if (pid[1] == pid[3]) break; + while (get("myphoto").src == p.src) + sleep(.1) +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:37:12
|
Revision: 1606 http://assorted.svn.sourceforge.net/assorted/?rev=1606&view=rev Author: yangzhang Date: 2010-04-01 18:37:05 +0000 (Thu, 01 Apr 2010) Log Message: ----------- added documentation Added Paths: ----------- facebook-tools/trunk/README Added: facebook-tools/trunk/README =================================================================== --- facebook-tools/trunk/README (rev 0) +++ facebook-tools/trunk/README 2010-04-01 18:37:05 UTC (rev 1606) @@ -0,0 +1,23 @@ +Overview +-------- + +Some number of handy tools for [Facebook]: + +- **getphotos.js**: a [Chickenfoot] script that downloads an entire sequence of + photos in Facebook. Go to the first photo, and the script will keep + advancing next-ward through the photos, printing the URL of each one (both to + the output console and to a `/tmp/output` file), until it hits the end. Note + that this tool will only help you download photos; it is unsuitable as an + archiving tool as it disregards a great deal of other information (tags, + captions, comments). + +- **fb.py**: utility for quickly playing with the [pyfacebook] API. I just + start up [ipython] and enter "import fb; f=fb.fb_session()" to start using + the pyfacebook object. + +- **update-facebook-friends** + +[Facebook]: http://facebook.com/ +[Chickenfoot]: http://groups.csail.mit.edu/uid/chickenfoot/ +[pyfacebook]: http://pyfacebook.googlecode.com/ +[ipython]: http://ipython.scipy.org/moin/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:36:21
|
Revision: 1605 http://assorted.svn.sourceforge.net/assorted/?rev=1605&view=rev Author: yangzhang Date: 2010-04-01 18:36:13 +0000 (Thu, 01 Apr 2010) Log Message: ----------- added sudoku solver Added Paths: ----------- sudoku-solver/ sudoku-solver/trunk/ sudoku-solver/trunk/src/ sudoku-solver/trunk/test/ sudoku-solver/trunk/test/easy.board sudoku-solver/trunk/test/hard.board Added: sudoku-solver/trunk/test/easy.board =================================================================== --- sudoku-solver/trunk/test/easy.board (rev 0) +++ sudoku-solver/trunk/test/easy.board 2010-04-01 18:36:13 UTC (rev 1605) @@ -0,0 +1,9 @@ + 7 + 67 18 + 19 5 2 +3 5 +57 3 21 +6 7 + 425 + 1 9 +9 4 Added: sudoku-solver/trunk/test/hard.board =================================================================== --- sudoku-solver/trunk/test/hard.board (rev 0) +++ sudoku-solver/trunk/test/hard.board 2010-04-01 18:36:13 UTC (rev 1605) @@ -0,0 +1,9 @@ + 31 7 4 + 7 9 + 8 4 3 + 85 7 + 79 16 + 59 6 8 + 6 82 + 56 81 +8 3 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:32:15
|
Revision: 1604 http://assorted.svn.sourceforge.net/assorted/?rev=1604&view=rev Author: yangzhang Date: 2010-04-01 18:32:08 +0000 (Thu, 01 Apr 2010) Log Message: ----------- add dist-packages to PYTHONPATH Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2010-04-01 18:30:33 UTC (rev 1603) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2010-04-01 18:32:08 UTC (rev 1604) @@ -34,6 +34,7 @@ # personal environment variables (TODO somehow factor this out) export EMAIL='Yang Zhang <ya...@gm...>' export DEBEMAIL='ya...@gm...' +export TERM=xterm-256color # TODO this is from sht; mv it to a mini-commons # TODO is this necessary in light of advanced var expansions? @@ -160,9 +161,13 @@ fi for ver in $PYTHONVERSION ; do pythonpath_prepend="$USER_PREFIX/lib/python$ver/site-packages:$pythonpath_prepend" + pythonpath_prepend="$USER_PREFIX/lib/python$ver/dist-packages:$pythonpath_prepend" pythonpath_prepend="$USER_TOAST_PREFIX/lib/python$ver/site-packages:$pythonpath_prepend" + pythonpath_prepend="$USER_TOAST_PREFIX/lib/python$ver/dist-packages:$pythonpath_prepend" pythonpath_prepend="/usr/local/lib/python$ver/site-packages:$pythonpath_prepend" + pythonpath_prepend="/usr/local/lib/python$ver/dist-packages:$pythonpath_prepend" pythonpath_prepend="$GLOBAL_PREFIX/lib/python$ver/site-packages:$pythonpath_prepend" + pythonpath_prepend="$GLOBAL_PREFIX/lib/python$ver/dist-packages:$pythonpath_prepend" done pythonpath_prepend="$pythonpath_prepend:/opt/zope/lib/python" prepend_var PYTHONPATH "$pythonpath_prepend" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2010-04-01 18:30:40
|
Revision: 1603 http://assorted.svn.sourceforge.net/assorted/?rev=1603&view=rev Author: yangzhang Date: 2010-04-01 18:30:33 +0000 (Thu, 01 Apr 2010) Log Message: ----------- added a lot more tests to determine buffering behavior Modified Paths: -------------- sandbox/trunk/src/nix/buffer/go.bash Added Paths: ----------- sandbox/trunk/src/nix/buffer/Gen.java Added: sandbox/trunk/src/nix/buffer/Gen.java =================================================================== --- sandbox/trunk/src/nix/buffer/Gen.java (rev 0) +++ sandbox/trunk/src/nix/buffer/Gen.java 2010-04-01 18:30:33 UTC (rev 1603) @@ -0,0 +1,9 @@ +public class Gen { + public static void main(String[] args) throws Exception { + for (int i = 0; i < 3; i++) { + System.out.println("a"); + System.err.println("b"); + Thread.sleep(300); + } + } +} Modified: sandbox/trunk/src/nix/buffer/go.bash =================================================================== --- sandbox/trunk/src/nix/buffer/go.bash 2010-04-01 18:29:16 UTC (rev 1602) +++ sandbox/trunk/src/nix/buffer/go.bash 2010-04-01 18:30:33 UTC (rev 1603) @@ -1,18 +1,43 @@ #!/usr/bin/env bash +set -x gcc -o gen gen.c # # These buffer. # -./gen 2>&1 | tee /dev/null -expect_unbuffer ./gen 2>&1 | tee /dev/null +#./gen 2>&1 | tee /dev/null +#expect_unbuffer ./gen 2>&1 | tee /dev/null +# +## +## These don't buffer. +## +# +#ssh localhost "$(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null +#ssh localhost "expect_unbuffer $(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null +#expect_unbuffer ssh localhost "$(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null +# +## This is, interestingly enough, not treated as a file. Equivalent to no +## piping. +#./gen > /dev/stdout +# This doesn't work. You really must use expect_unbuffer everywhere in your +# pipeline. +expect_unbuffer bash sub.bash + # -# These don't buffer. +# In a pipeline. # -ssh localhost "$(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null -ssh localhost "expect_unbuffer $(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null -expect_unbuffer ssh localhost "$(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null +# Everything shows up all at once at the end (as expected). +./gen 2>&1 | sed 's/ / /' | tee /dev/null +# XXX why does this hang?! +expect_unbuffer ./gen 2>&1 | expect_unbuffer sed 's/ / /' | tee /dev/null + +# +# Java is unaffected. +# + +javac Gen.java +java Gen | tee /dev/null This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |