assorted-commits Mailing List for Assorted projects (Page 49)
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...> - 2008-05-04 17:46:06
|
Revision: 702 http://assorted.svn.sourceforge.net/assorted/?rev=702&view=rev Author: yangzhang Date: 2008-05-04 10:46:02 -0700 (Sun, 04 May 2008) Log Message: ----------- fixed indentation Modified Paths: -------------- configs/trunk/src/contestapplet.conf Modified: configs/trunk/src/contestapplet.conf =================================================================== --- configs/trunk/src/contestapplet.conf 2008-05-04 17:45:26 UTC (rev 701) +++ configs/trunk/src/contestapplet.conf 2008-05-04 17:46:02 UTC (rev 702) @@ -1,4 +1,4 @@ -// vim:noet:sw=2:ts=2 +// vim:et:sw=2:ts=2 // TODO // - strip out all comments This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-04 17:45:22
|
Revision: 701 http://assorted.svn.sourceforge.net/assorted/?rev=701&view=rev Author: yangzhang Date: 2008-05-04 10:45:26 -0700 (Sun, 04 May 2008) Log Message: ----------- added some more to the readme Modified Paths: -------------- configs/trunk/README Modified: configs/trunk/README =================================================================== --- configs/trunk/README 2008-05-04 17:44:31 UTC (rev 700) +++ configs/trunk/README 2008-05-04 17:45:26 UTC (rev 701) @@ -24,3 +24,17 @@ ~`. These are separate because I too often need custom bash/emacs/vim configurations (refer to the default.* files to see how to source the globally installed configurations). + +To set up the author's topcoder environment, run `src/topcoder/setup.bash`. + +Features +-------- + +=== Vim === + +- search parent directories for project-wide settings + +=== screen === + +- sensible control key (ctrl-\) +- informative status string This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-04 17:44:24
|
Revision: 700 http://assorted.svn.sourceforge.net/assorted/?rev=700&view=rev Author: yangzhang Date: 2008-05-04 10:44:31 -0700 (Sun, 04 May 2008) Log Message: ----------- added signature Modified Paths: -------------- configs/trunk/setup-yang.bash Added Paths: ----------- configs/trunk/src/signature Modified: configs/trunk/setup-yang.bash =================================================================== --- configs/trunk/setup-yang.bash 2008-05-04 07:51:01 UTC (rev 699) +++ configs/trunk/setup-yang.bash 2008-05-04 17:44:31 UTC (rev 700) @@ -19,4 +19,5 @@ install .Xdefaults Xdefaults install .synergy.conf synergy.conf install .unison unison +install .signature signature # TODO figure out a place to put the .profile Added: configs/trunk/src/signature =================================================================== --- configs/trunk/src/signature (rev 0) +++ configs/trunk/src/signature 2008-05-04 17:44:31 UTC (rev 700) @@ -0,0 +1,2 @@ +Yang Zhang +http://www.mit.edu/~y_z/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-04 07:50:59
|
Revision: 699 http://assorted.svn.sourceforge.net/assorted/?rev=699&view=rev Author: yangzhang Date: 2008-05-04 00:51:01 -0700 (Sun, 04 May 2008) Log Message: ----------- added clarifying note Modified Paths: -------------- sandbox/trunk/src/c/vaargs.c Modified: sandbox/trunk/src/c/vaargs.c =================================================================== --- sandbox/trunk/src/c/vaargs.c 2008-05-04 07:50:13 UTC (rev 698) +++ sandbox/trunk/src/c/vaargs.c 2008-05-04 07:51:01 UTC (rev 699) @@ -38,6 +38,8 @@ // This is how you pass a suffix of the va_list to a another function. Here we // have h passing everything but garbage on to g. This requires h to extract // out the first argument and pass that as a normal arg. +// XXX: although this seems to work on Linux, check that this is the right +// (portable) way to do this. void h(int garbage, ...) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-04 07:50:15
|
Revision: 698 http://assorted.svn.sourceforge.net/assorted/?rev=698&view=rev Author: yangzhang Date: 2008-05-04 00:50:13 -0700 (Sun, 04 May 2008) Log Message: ----------- polishing blocks.c Modified Paths: -------------- sandbox/trunk/src/c/blocks.c Modified: sandbox/trunk/src/c/blocks.c =================================================================== --- sandbox/trunk/src/c/blocks.c 2008-05-04 07:27:22 UTC (rev 697) +++ sandbox/trunk/src/c/blocks.c 2008-05-04 07:50:13 UTC (rev 698) @@ -6,17 +6,39 @@ enum { blk = 10 }; enum { datlen = 2 * blk }; +/** + * Calculate the number of blocks in a segment of length \a i. + * Mathematically, this is \code ceil(i / blk) \endcode. + * Equivalent to \code (i - 1) / blk + 1 \endcode, but without the + * arithmetic underflow. + * + * E.g., with a block size of 10: + * + * \code + * nblocks( 0) == 0 && + * nblocks( 1) == 1 && nblocks(10) == 1 && + * nblocks(11) == 2 && ... + * \endcode + */ +inline uint32_t +nblocks(uint32_t i) +{ + return (i + blk - 1) / blk; +} + void f(uint32_t off, uint32_t len) { uint32_t end = off + len; - uint32_t fstblk = off / blk, lstblk = (end + blk - 1) / blk; - printf("f(off %4d, len %4d), fstblk %2d, lstblk %2d\n", off, len, fstblk, lstblk); + uint32_t fstblk = off / blk, lstblk = nblocks(end); + printf("f(off %4d, len %4d), fstblk %2d, lstblk %2d\n", + off, len, fstblk, lstblk); char *p = 0; for (uint32_t i = fstblk; i < lstblk; i++) { uint32_t blkoff = i == fstblk ? off % blk : 0; uint32_t blklen = min(end - i * blk, blk) - blkoff; - printf(" i %2d | blkoff %4d | blklen %4d | p %04p\n", i, blkoff, blklen, p); + printf(" i %2d | blkoff %4d | blklen %4d | p %04p\n", + i, blkoff, blklen, p); p += blklen; } printf("\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-04 07:27:24
|
Revision: 697 http://assorted.svn.sourceforge.net/assorted/?rev=697&view=rev Author: yangzhang Date: 2008-05-04 00:27:22 -0700 (Sun, 04 May 2008) Log Message: ----------- added subprocess Added Paths: ----------- sandbox/trunk/src/c/subprocs.c Added: sandbox/trunk/src/c/subprocs.c =================================================================== --- sandbox/trunk/src/c/subprocs.c (rev 0) +++ sandbox/trunk/src/c/subprocs.c 2008-05-04 07:27:22 UTC (rev 697) @@ -0,0 +1,14 @@ +// Performing ctrl-c from the shell actually sends a sigint to the entire +// process group, i.e. the top process plus any subprocesses. You can get the +// same effect by running this command as a background shell job and killing +// the job with `kill %%` or `kill %+`. + +#include <unistd.h> + +int +main() +{ + pid_t pid = fork(); + sleep(30); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-02 03:13:07
|
Revision: 696 http://assorted.svn.sourceforge.net/assorted/?rev=696&view=rev Author: yangzhang Date: 2008-05-01 20:13:14 -0700 (Thu, 01 May 2008) Log Message: ----------- added basic tamer demo Added Paths: ----------- sandbox/trunk/src/cc/tamer/ sandbox/trunk/src/cc/tamer/basics.tt Added: sandbox/trunk/src/cc/tamer/basics.tt =================================================================== --- sandbox/trunk/src/cc/tamer/basics.tt (rev 0) +++ sandbox/trunk/src/cc/tamer/basics.tt 2008-05-02 03:13:14 UTC (rev 696) @@ -0,0 +1,42 @@ +#include <iostream> +#include <boost/scoped_array.hpp> +#include <commons/check.h> +#include <commons/die.h> +#include <tamer/tamer.hh> +#include <tamer/fd.hh> +#include <tamer/bufferedio.hh> + +using namespace std; +using namespace boost; +using namespace commons; +using namespace tamer; +using namespace tamer::fdx; + +const int port = 8989; + +class C +{ + tamed void f() { return 0; } +}; + +tamed void +go() +{ + tvars { fd listener, conn; } + twait { tcp_listen(port, make_event(listener)); } + checkdie(listener, "listen"); + while (1) { + twait { listener.accept(0, 0, make_event(conn)); } + checkdie(conn, "accept"); + cout << "handling" << endl; + } +} + +int +main() +{ + initialize(); + go(); + loop(); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-02 03:12:44
|
Revision: 695 http://assorted.svn.sourceforge.net/assorted/?rev=695&view=rev Author: yangzhang Date: 2008-05-01 20:12:51 -0700 (Thu, 01 May 2008) Log Message: ----------- added basic st demo Added Paths: ----------- sandbox/trunk/src/cc/st/ sandbox/trunk/src/cc/st/basics.cc Added: sandbox/trunk/src/cc/st/basics.cc =================================================================== --- sandbox/trunk/src/cc/st/basics.cc (rev 0) +++ sandbox/trunk/src/cc/st/basics.cc 2008-05-02 03:12:51 UTC (rev 695) @@ -0,0 +1,42 @@ +#include <cstdio> +#include <iostream> + +#include <commons/check.h> +#include <commons/closing.h> +#include <commons/sockets.h> +#include <commons/st/st.h> + +using namespace std; +using namespace commons; + +void* +f(void *p) +{ + stfd s = tcp_connect("www.google.com", 80); + return NULL; +} + +void* +g(void *p) +{ + st_thread_t t = (st_thread_t) p; + st_sleep(1); + printf("interrupting!\n"); + st_thread_interrupt(t); + printf("interrupted!\n"); + st_sleep(1); + printf("waited\n"); + return NULL; +} + +int +main() +{ + check0(st_init()); + st_thread_t t1 = checkpass(st_thread_create(&f, (void*)"abc", 0, 0)); + checkpass(st_thread_create(&f, (void*)"abc", 0, 0)); + checkpass(st_thread_create(&g, (void*)t1, 0, 0)); + //check0(st_thread_join(t, NULL)); + st_thread_exit(NULL); + return 1; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-30 21:33:38
|
Revision: 694 http://assorted.svn.sourceforge.net/assorted/?rev=694&view=rev Author: yangzhang Date: 2008-04-30 14:33:37 -0700 (Wed, 30 Apr 2008) Log Message: ----------- python commons 0.3 release Added Paths: ----------- python-commons/tags/0.3/ Copied: python-commons/tags/0.3 (from rev 692, python-commons/trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-30 17:41:53
|
Revision: 693 http://assorted.svn.sourceforge.net/assorted/?rev=693&view=rev Author: yangzhang Date: 2008-04-30 10:42:00 -0700 (Wed, 30 Apr 2008) Log Message: ----------- removed extraneous prints, minor upgrade release Modified Paths: -------------- python-commons/trunk/publish.bash python-commons/trunk/setup.py python-commons/trunk/src/commons/files.py Modified: python-commons/trunk/publish.bash =================================================================== --- python-commons/trunk/publish.bash 2008-04-30 07:06:19 UTC (rev 692) +++ python-commons/trunk/publish.bash 2008-04-30 17:42:00 UTC (rev 693) @@ -5,7 +5,7 @@ } fullname='Python Commons' -version=0.3 +version=0.3.1 license=psf websrcs=( README ) rels=( pypi: ) Modified: python-commons/trunk/setup.py =================================================================== --- python-commons/trunk/setup.py 2008-04-30 07:06:19 UTC (rev 692) +++ python-commons/trunk/setup.py 2008-04-30 17:42:00 UTC (rev 693) @@ -9,7 +9,7 @@ pkg_info_text = """ Metadata-Version: 1.1 Name: python-commons -Version: 0.3 +Version: 0.3.1 Author: Yang Zhang Author-email: yaaang NOSPAM at REMOVECAPS gmail Home-page: http://assorted.sourceforge.net/python-commons Modified: python-commons/trunk/src/commons/files.py =================================================================== --- python-commons/trunk/src/commons/files.py 2008-04-30 07:06:19 UTC (rev 692) +++ python-commons/trunk/src/commons/files.py 2008-04-30 17:42:00 UTC (rev 693) @@ -135,7 +135,6 @@ with file( path ) as f: cache_version = load(f) except IOError, (errno, errstr): if errno != 2: raise - print cache_version, fresh_version if cache_version is None or fresh_version > cache_version: with file( path, 'w' ) as f: dump(fresh_version, f) return True @@ -164,11 +163,9 @@ """ if versioned_guard( version_path, fresh_version ): # cache obsolete, force-fetch new data - print 'here' result = cache_func() with file(cache_path, 'w') as f: dump(result, f) return result else: # cache up-to-date (should be available since dlcs-timestamp exists!) - print 'there' with file(cache_path) as f: return load(f) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-30 07:06:25
|
Revision: 692 http://assorted.svn.sourceforge.net/assorted/?rev=692&view=rev Author: yangzhang Date: 2008-04-30 00:06:19 -0700 (Wed, 30 Apr 2008) Log Message: ----------- new version! Modified Paths: -------------- python-commons/trunk/setup.py Modified: python-commons/trunk/setup.py =================================================================== --- python-commons/trunk/setup.py 2008-04-30 07:05:01 UTC (rev 691) +++ python-commons/trunk/setup.py 2008-04-30 07:06:19 UTC (rev 692) @@ -9,7 +9,7 @@ pkg_info_text = """ Metadata-Version: 1.1 Name: python-commons -Version: 0.2 +Version: 0.3 Author: Yang Zhang Author-email: yaaang NOSPAM at REMOVECAPS gmail Home-page: http://assorted.sourceforge.net/python-commons This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-30 07:05:04
|
Revision: 691 http://assorted.svn.sourceforge.net/assorted/?rev=691&view=rev Author: yangzhang Date: 2008-04-30 00:05:01 -0700 (Wed, 30 Apr 2008) Log Message: ----------- new version! Modified Paths: -------------- python-commons/trunk/publish.bash Modified: python-commons/trunk/publish.bash =================================================================== --- python-commons/trunk/publish.bash 2008-04-29 23:03:05 UTC (rev 690) +++ python-commons/trunk/publish.bash 2008-04-30 07:05:01 UTC (rev 691) @@ -5,7 +5,7 @@ } fullname='Python Commons' -version=0.2 +version=0.3 license=psf websrcs=( README ) rels=( pypi: ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-29 23:03:05
|
Revision: 690 http://assorted.svn.sourceforge.net/assorted/?rev=690&view=rev Author: yangzhang Date: 2008-04-29 16:03:05 -0700 (Tue, 29 Apr 2008) Log Message: ----------- fixed bug in versioned_guard; clarified docstring on versioned_cache Modified Paths: -------------- python-commons/trunk/src/commons/files.py Modified: python-commons/trunk/src/commons/files.py =================================================================== --- python-commons/trunk/src/commons/files.py 2008-04-29 23:00:50 UTC (rev 689) +++ python-commons/trunk/src/commons/files.py 2008-04-29 23:03:05 UTC (rev 690) @@ -130,23 +130,26 @@ version or doesn't exist). @rtype: bool """ + cache_version = None try: with file( path ) as f: cache_version = load(f) except IOError, (errno, errstr): if errno != 2: raise + print cache_version, fresh_version + if cache_version is None or fresh_version > cache_version: + with file( path, 'w' ) as f: dump(fresh_version, f) return True else: - if fresh_version > cache_version: - with file( path, 'w' ) as f: dump(fresh_version, f) - return True - else: - return False + return False def versioned_cache(version_path, fresh_version, cache_path, cache_func): """ If fresh_version is newer than the version in version_path, then invoke cache_func and cache the result in cache_path (using pickle). + Note the design flaw with L{versioned_guard}: the updated version value is + stored immediately, rather than after updating the cache. + @param version_path: The path to the file version. @type version_path: str This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-29 23:00:45
|
Revision: 689 http://assorted.svn.sourceforge.net/assorted/?rev=689&view=rev Author: yangzhang Date: 2008-04-29 16:00:50 -0700 (Tue, 29 Apr 2008) Log Message: ----------- added retry_exp_backoff() Modified Paths: -------------- python-commons/trunk/src/commons/networking.py Modified: python-commons/trunk/src/commons/networking.py =================================================================== --- python-commons/trunk/src/commons/networking.py 2008-04-29 05:18:57 UTC (rev 688) +++ python-commons/trunk/src/commons/networking.py 2008-04-29 23:00:50 UTC (rev 689) @@ -6,6 +6,7 @@ """ import os, sys +from time import * class NoMacAddrError( Exception ): pass @@ -37,3 +38,28 @@ raise NoMacAddrError return mac +def retry_exp_backoff(initial_backoff, multiplier, func): + """ + Repeatedly invoke L{func} until it succeeds (returns non-None), with + exponentially growing backoff delay between each try. + + @param initial_backoff: The initial backoff. + @type initial_backoff: float + + @param multiplier: The amount by which the backoff is multiplied on each + failure. + @type multiplier: float + + @param func: The zero-argument function to be invoked that returns True on + success and False on failure. + @type func: function + + @return: The result of the function + """ + backoff = initial_backoff + while True: + res = func() + if res is not None: return res + print 'backing off for', backoff + sleep(backoff) + backoff = multiplier * backoff This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-29 05:18:53
|
Revision: 688 http://assorted.svn.sourceforge.net/assorted/?rev=688&view=rev Author: yangzhang Date: 2008-04-28 22:18:57 -0700 (Mon, 28 Apr 2008) Log Message: ----------- added versioned_guard, versioned_cache Modified Paths: -------------- python-commons/trunk/src/commons/files.py Modified: python-commons/trunk/src/commons/files.py =================================================================== --- python-commons/trunk/src/commons/files.py 2008-04-29 00:32:42 UTC (rev 687) +++ python-commons/trunk/src/commons/files.py 2008-04-29 05:18:57 UTC (rev 688) @@ -14,7 +14,7 @@ from __future__ import with_statement import os, re, tempfile - +from cPickle import * from path import path def soft_makedirs( path ): @@ -113,3 +113,59 @@ def close( self ): self.reader.close() self.writer.close() + +def versioned_guard(path, fresh_version): + """ + Maintain a version object. This is useful for working with versioned + caches. + + @param path: The path to the file containing the cached version object. + @type path: str + + @param fresh_version: The actual latest version that the cached version + should be compared against. + @type fresh_version: object (any type that can be compared) + + @return: True iff the cached version is obsolete (less than the fresh + version or doesn't exist). + @rtype: bool + """ + try: + with file( path ) as f: cache_version = load(f) + except IOError, (errno, errstr): + if errno != 2: raise + return True + else: + if fresh_version > cache_version: + with file( path, 'w' ) as f: dump(fresh_version, f) + return True + else: + return False + +def versioned_cache(version_path, fresh_version, cache_path, cache_func): + """ + If fresh_version is newer than the version in version_path, then invoke + cache_func and cache the result in cache_path (using pickle). + + @param version_path: The path to the file version. + @type version_path: str + + @param fresh_version: The actual, up-to-date version value. + @type fresh_version: object (any type that can be compared) + + @param cache_path: The path to the cached data. + @type cache_path: str + + @param cache_func: The function that produces the fresh data to be cached. + @type cache_func: function (no arguments) + """ + if versioned_guard( version_path, fresh_version ): + # cache obsolete, force-fetch new data + print 'here' + result = cache_func() + with file(cache_path, 'w') as f: dump(result, f) + return result + else: + # cache up-to-date (should be available since dlcs-timestamp exists!) + print 'there' + with file(cache_path) as f: return load(f) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-29 00:32:35
|
Revision: 687 http://assorted.svn.sourceforge.net/assorted/?rev=687&view=rev Author: yangzhang Date: 2008-04-28 17:32:42 -0700 (Mon, 28 Apr 2008) Log Message: ----------- added file_memoized, file_string_memoized, pickle_memoized Modified Paths: -------------- python-commons/trunk/src/commons/decs.py Modified: python-commons/trunk/src/commons/decs.py =================================================================== --- python-commons/trunk/src/commons/decs.py 2008-04-29 00:31:41 UTC (rev 686) +++ python-commons/trunk/src/commons/decs.py 2008-04-29 00:32:42 UTC (rev 687) @@ -7,7 +7,9 @@ @todo: Move the actual decorators to modules based on their topic. """ +from __future__ import with_statement import functools, inspect, xmlrpclib +from cPickle import * def wrap_callable(any_callable, before, after): """ @@ -90,3 +92,65 @@ else: return 0 return wrapper + +########################################################## + +def file_memoized(serializer, deserializer, pathfunc): + """ + The string result of the given function is saved to the given path. + + Example:: + + @file_memoized(lambda x,f: f.write(x), + lambda f: f.read(), + lambda: "/tmp/cache") + def foo(): return "hello" + + @file_memoized(pickle.dump, + pickle.load, + lambda x,y: "/tmp/cache-%d-%d" % (x,y)) + def foo(x,y): return "hello %d %d" % (x,y) + + @param serializer: The function to serialize the return value into a + string. This should take the return value object and + the file object. + @type serializer: function + + @param deserializer: The function te deserialize the cache file contents + into the return value. This should take the file + object and return a string. + type: deserializer: function + + @param pathfunc: Returns the path where the files should be saved. This + should be able to take the same arguments as the original + function. + @type pathfunc: str + """ + def dec(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + p = pathfunc(*args, **kwargs) + try: + with file(p) as f: + return deserializer(f) + except IOError, (errno, errstr): + if errno != 2: raise + with file(p, 'w') as f: + x = func(*args, **kwargs) + serializer(x, f) + return x + return wrapper + return dec + +def file_string_memoized(pathfunc): + """ + Wrapper around L{file_memoized} that expects the decorated function to + return strings, so the string is written verbatim. + """ + return file_memoized(lambda x,f: f.write(x), lambda f: f.read(), pathfunc) + +def pickle_memoized(pathfunc): + """ + Wrapper around L{file_memoized} that uses pickle. + """ + return file_memoized(dump, load, pathfunc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-29 00:31:42
|
Revision: 686 http://assorted.svn.sourceforge.net/assorted/?rev=686&view=rev Author: yangzhang Date: 2008-04-28 17:31:41 -0700 (Mon, 28 Apr 2008) Log Message: ----------- addec countstep Modified Paths: -------------- python-commons/trunk/src/commons/seqs.py Modified: python-commons/trunk/src/commons/seqs.py =================================================================== --- python-commons/trunk/src/commons/seqs.py 2008-04-25 21:38:05 UTC (rev 685) +++ python-commons/trunk/src/commons/seqs.py 2008-04-29 00:31:41 UTC (rev 686) @@ -341,6 +341,15 @@ del chunk[ ( i + 1 ) % n : ] yield chunk +def countstep(start, step): + """ + Generate [start, start+step, start+2*step, start+3*step, ...]. + """ + i = start + while True: + yield i + i += step + def take(n, seq): return list(islice(seq, n)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-25 21:38:35
|
Revision: 685 http://assorted.svn.sourceforge.net/assorted/?rev=685&view=rev Author: yangzhang Date: 2008-04-25 14:38:05 -0700 (Fri, 25 Apr 2008) Log Message: ----------- added printf() demo Added Paths: ----------- sandbox/trunk/src/c/printf.c Added: sandbox/trunk/src/c/printf.c =================================================================== --- sandbox/trunk/src/c/printf.c (rev 0) +++ sandbox/trunk/src/c/printf.c 2008-04-25 21:38:05 UTC (rev 685) @@ -0,0 +1,12 @@ +// Demo the various printf() flags. + +#include <stddef.h> +#include <stdio.h> + +int +main() +{ + size_t x = 3; + printf("%zu\n", x); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-24 23:57:48
|
Revision: 684 http://assorted.svn.sourceforge.net/assorted/?rev=684&view=rev Author: yangzhang Date: 2008-04-24 16:57:51 -0700 (Thu, 24 Apr 2008) Log Message: ----------- updated readme Modified Paths: -------------- java-reactor/trunk/README Modified: java-reactor/trunk/README =================================================================== --- java-reactor/trunk/README 2008-04-24 21:17:26 UTC (rev 683) +++ java-reactor/trunk/README 2008-04-24 23:57:51 UTC (rev 684) @@ -4,15 +4,14 @@ -------- This is a completely minimal implementation of a select-based reactor framework -for event-based asynchronous IO programming. The reactor core supports -scheduling of tasks (a la Twisted, asio, etc.). This was written after -witnessing the inefficiency of various other reactor-based implementations - at -least for the very particular environment that is PlanetLab. It also helped us -remove the need for a separate thread for the scheduled executor tasks - these -are run in-line. +for event-based asynchronous IO programming. The reactor core supports +scheduling of tasks (a la Twisted, asio, etc.). This was written for the +constrained-resource environment that is PlanetLab. It also helped us remove +the need for a separate thread for the scheduled executor tasks - these are run +in-line (using timeouts to select). Aside from its simplicity, efficiency, and support for scheduled tasks, it also -has no dependencies except for Java 6. +has no dependencies except for Java 6. Currently only UDP is supported. Related Work ------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-24 21:17:20
|
Revision: 683 http://assorted.svn.sourceforge.net/assorted/?rev=683&view=rev Author: yangzhang Date: 2008-04-24 14:17:26 -0700 (Thu, 24 Apr 2008) Log Message: ----------- moved preferred valgrind options to bashrc.bash (xvalgrind) since scripts, etc. using valgrind cannot override these settings Modified Paths: -------------- configs/trunk/setup-yang.bash Removed Paths: ------------- configs/trunk/src/valgrindrc Modified: configs/trunk/setup-yang.bash =================================================================== --- configs/trunk/setup-yang.bash 2008-04-24 20:51:27 UTC (rev 682) +++ configs/trunk/setup-yang.bash 2008-04-24 21:17:26 UTC (rev 683) @@ -14,7 +14,6 @@ install .astylerc astylerc install .screenrc screenrc install .pythonrc.py pythonrc.py -install .valgrindrc valgrindrc install .darcs/ darcs/boring install .subversion/ subversion/config install .Xdefaults Xdefaults Deleted: configs/trunk/src/valgrindrc =================================================================== --- configs/trunk/src/valgrindrc 2008-04-24 20:51:27 UTC (rev 682) +++ configs/trunk/src/valgrindrc 2008-04-24 21:17:26 UTC (rev 683) @@ -1,7 +0,0 @@ ---track-fds=yes ---db-attach=yes ---verbose ---tool=memcheck ---leak-check=yes ---leak-resolution=high ---show-reachable=yes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-24 20:51:38
|
Revision: 682 http://assorted.svn.sourceforge.net/assorted/?rev=682&view=rev Author: yangzhang Date: 2008-04-24 13:51:27 -0700 (Thu, 24 Apr 2008) Log Message: ----------- added simple valgrind test Added Paths: ----------- sandbox/trunk/src/cc/valgrind/ sandbox/trunk/src/cc/valgrind/corrupt.cc Added: sandbox/trunk/src/cc/valgrind/corrupt.cc =================================================================== --- sandbox/trunk/src/cc/valgrind/corrupt.cc (rev 0) +++ sandbox/trunk/src/cc/valgrind/corrupt.cc 2008-04-24 20:51:27 UTC (rev 682) @@ -0,0 +1,12 @@ +// Just so I have something to test out valgrind against. + +#include <stdlib.h> +#include <string.h> + +int +main() +{ + void *p = malloc(4); + while (1) memset(p, 0, 8); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-24 16:28:20
|
Revision: 681 http://assorted.svn.sourceforge.net/assorted/?rev=681&view=rev Author: yangzhang Date: 2008-04-24 09:27:39 -0700 (Thu, 24 Apr 2008) Log Message: ----------- failstop Modified Paths: -------------- simple-build/trunk/setup.bash Modified: simple-build/trunk/setup.bash =================================================================== --- simple-build/trunk/setup.bash 2008-04-24 16:26:11 UTC (rev 680) +++ simple-build/trunk/setup.bash 2008-04-24 16:27:39 UTC (rev 681) @@ -1,7 +1,7 @@ #!/usr/bin/env bash pkg=simple-build -. simple-setup.bash +. simple-setup.bash || exit 1 install_strip bin/ src/googlecode_upload.py install bin/ src/{build.bash,capture-javac-deps,out/simple-build} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-24 16:27:30
|
Revision: 680 http://assorted.svn.sourceforge.net/assorted/?rev=680&view=rev Author: yangzhang Date: 2008-04-24 09:26:11 -0700 (Thu, 24 Apr 2008) Log Message: ----------- updated readme Modified Paths: -------------- js-beautifier/trunk/README Modified: js-beautifier/trunk/README =================================================================== --- js-beautifier/trunk/README 2008-04-24 16:13:04 UTC (rev 679) +++ js-beautifier/trunk/README 2008-04-24 16:26:11 UTC (rev 680) @@ -4,8 +4,22 @@ Overview -------- -This is a wrapper for the [elfz Javascript beautifier]. I found this to be the best Javascript beautifier available, but I needed to be able to run it in batch and from shell scripts. Since I needed also to parse Facebook's monstrous common.js file, I decided to also look into [Tamarin], Adobe's JIT gift to Mozilla. It provides the minimal file IO facilities needed to run this beautifier tool standalone. +This is a wrapper for the [elfz Javascript beautifier]. I found this to be the +best Javascript beautifier available, but I needed to be able to run it in +batch and from shell scripts. Since I needed also to parse Facebook's +monstrous common.js file, I decided to also look into [Tamarin], Adobe's JIT +gift to Mozilla. It provides the minimal file IO facilities needed to run this +beautifier tool standalone, but most importantly, I had to beautify a lot of +code, so it behooved me to use the fastest JS implementation available. [elfz Javascript beautifier]: http://elfz.laacz.lv/beautify/ [Tamarin]: http://www.mozilla.org/projects/tamarin/ +Setup +----- + +To build Tamarin, you need to follow the instructions on the [MDC]. Tamarin is +a bit different from most JS implementations in that compilation to bytecode is +performed separately from the execution (javac:java::asc:avmplus). + +[MDC]: http://developer.mozilla.org/en/docs/Tamarin_Build_Documentation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-24 16:14:08
|
Revision: 679 http://assorted.svn.sourceforge.net/assorted/?rev=679&view=rev Author: yangzhang Date: 2008-04-24 09:13:04 -0700 (Thu, 24 Apr 2008) Log Message: ----------- updated install script Modified Paths: -------------- shell-tools/trunk/setup.bash Modified: shell-tools/trunk/setup.bash =================================================================== --- shell-tools/trunk/setup.bash 2008-04-24 16:11:51 UTC (rev 678) +++ shell-tools/trunk/setup.bash 2008-04-24 16:13:04 UTC (rev 679) @@ -7,9 +7,15 @@ . src/bash-commons/simple-setup.bash for path in "src/bash-commons/"* ; do - install bin/ "$path" + install bin/ "$path" done +for path in "src/"*.hs ; do + install bin/ "$path" +done + for path in "src/"*.* ; do - install_strip bin/ "$path" + if [[ "$path" == "${path%.hs}" ]] + then install_strip bin/ "$path" + fi done This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-04-24 16:11:54
|
Revision: 678 http://assorted.svn.sourceforge.net/assorted/?rev=678&view=rev Author: yangzhang Date: 2008-04-24 09:11:51 -0700 (Thu, 24 Apr 2008) Log Message: ----------- added reconf, kreconf, bbfix Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2008-04-23 20:41:17 UTC (rev 677) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2008-04-24 16:11:51 UTC (rev 678) @@ -203,7 +203,7 @@ } function ll { - l -Al "$@" + l -Ahl "$@" } function wgr { @@ -530,8 +530,39 @@ done } +function kreconf() { + reconf -k "$@" +} + +function reconf() { + svn -q up + + if svn status | grep -q '^C' + then return 1 + fi + + make -sj2 distclean || true + make -sj2 clean || true + + if [[ "$1" == '-k' ]] + then shift; cscope -bqRk + else cscope -bqR + fi + ctags-exuberant -R . + + if [[ -f Doxyfile ]] + then doxygen + fi + + if [[ -x configure ]] + then ./configure --quiet + fi + + make -sj2 +} + #function set_title() { -# if [ $# -eq 0 ] ; then +# if [ $# -eq 0 ] ; then # eval set -- "$PWD" # fi # Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-04-23 20:41:17 UTC (rev 677) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-04-24 16:11:51 UTC (rev 678) @@ -406,6 +406,25 @@ sort -u } +bbfix() { + # bbfix, by Patrick Reynolds (reynolds .at. cs duke edu) + # Too trivial to copyright. It's in the public domain! + # + # Usage: + # ./bbfix foo.eps + + if [ $# = 0 ]; then + echo "Usage:" + echo " $0 file.eps [file.eps [file.eps [...]]]" + exit + fi + + for fn in "$@"; do + BB=`gs -q -sDEVICE=bbox -dNOPAUSE -dBATCH $fn 2>&1 | grep '^%%BoundingBox'` + perl -i -pne 's/^%%BoundingBox.*/'"$BB"'/' $fn + done +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |