assorted-commits Mailing List for Assorted projects (Page 3)
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...> - 2013-03-31 22:39:08
|
Revision: 1852
http://sourceforge.net/p/assorted/svn/1852
Author: yangzhang
Date: 2013-03-31 22:39:05 +0000 (Sun, 31 Mar 2013)
Log Message:
-----------
Add extract-audio
Modified Paths:
--------------
shell-tools/trunk/src/bash-commons/common.bash
Modified: shell-tools/trunk/src/bash-commons/common.bash
===================================================================
--- shell-tools/trunk/src/bash-commons/common.bash 2013-03-31 22:38:44 UTC (rev 1851)
+++ shell-tools/trunk/src/bash-commons/common.bash 2013-03-31 22:39:05 UTC (rev 1852)
@@ -840,6 +840,10 @@
done
}
+extract-audio() {
+ ffmpeg -i "$1" -acodec copy "${1%.*}.mp3"
+}
+
#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.
|
|
From: <yan...@us...> - 2013-03-31 22:38:46
|
Revision: 1851
http://sourceforge.net/p/assorted/svn/1851
Author: yangzhang
Date: 2013-03-31 22:38:44 +0000 (Sun, 31 Mar 2013)
Log Message:
-----------
Add update-agent, add more comments on refresh-agent
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 2013-03-31 22:35:43 UTC (rev 1850)
+++ shell-tools/trunk/src/bash-commons/bashrc.bash 2013-03-31 22:38:44 UTC (rev 1851)
@@ -895,12 +895,20 @@
# If current socket is no longer there (forwarded ssh agent connection no
# longer exists) but the keychain script has a good socket, then use that one.
+# Useful if for instance you started a screen session from one ssh connection
+# (which has its own forwarded agent socket), then that connection dies and you
+# reconnect (now with a different forwarded agent socket), but all your screen
+# session shells still exist with a reference to the old socket - with this,
+# and with a run of update-agent, the shells can now use the new socket.
refresh-agent() {
if [[ ! -S $SSH_AUTH_SOCK ]] && ( . ~/.keychain/$HOSTNAME-sh && [[ -S $SSH_AUTH_SOCK ]] )
then . ~/.keychain/$HOSTNAME-sh
fi
}
+# Save the current environment's agent.
+update-agent() { keychain --nogui --inherit any; }
+
PROMPT_COMMAND=refresh-agent
# TODO note that bash_completion usually does a ton of stuff (and in
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2013-03-31 22:35:46
|
Revision: 1850
http://sourceforge.net/p/assorted/svn/1850
Author: yangzhang
Date: 2013-03-31 22:35:43 +0000 (Sun, 31 Mar 2013)
Log Message:
-----------
Remove TODO on diff btwn PROMPT_COMMAND and PS1
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 2013-03-31 22:33:40 UTC (rev 1849)
+++ shell-tools/trunk/src/bash-commons/bashrc.bash 2013-03-31 22:35:43 UTC (rev 1850)
@@ -912,18 +912,7 @@
then . /etc/bash_completion
fi
- # TODO figure out tradeoffs btwn PROMPT_COMMAND and using special title escape in PS1
- # PROMPT_COMMAND is the title
- #case "$TERM" in
- #xterm*|rxvt*)
- # PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
- # ;;
- #*)
- # ;;
- #esac
-
setup_prompt
-
fi
# Load virtualenvwrapper commands
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2013-03-31 22:33:42
|
Revision: 1849
http://sourceforge.net/p/assorted/svn/1849
Author: yangzhang
Date: 2013-03-31 22:33:40 +0000 (Sun, 31 Mar 2013)
Log Message:
-----------
Add refresh-agent as PROMPT_COMMAND
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 2013-03-29 01:25:29 UTC (rev 1848)
+++ shell-tools/trunk/src/bash-commons/bashrc.bash 2013-03-31 22:33:40 UTC (rev 1849)
@@ -893,6 +893,16 @@
then eval `keychain --eval --nogui $keychain_flags $keyfile 2> /dev/null`
fi
+# If current socket is no longer there (forwarded ssh agent connection no
+# longer exists) but the keychain script has a good socket, then use that one.
+refresh-agent() {
+ if [[ ! -S $SSH_AUTH_SOCK ]] && ( . ~/.keychain/$HOSTNAME-sh && [[ -S $SSH_AUTH_SOCK ]] )
+ then . ~/.keychain/$HOSTNAME-sh
+ fi
+}
+
+PROMPT_COMMAND=refresh-agent
+
# TODO note that bash_completion usually does a ton of stuff (and in
# particular it re/undefines `have`), so it's best to move this near the
# top
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2013-03-29 01:25:31
|
Revision: 1848
http://sourceforge.net/p/assorted/svn/1848
Author: yangzhang
Date: 2013-03-29 01:25:29 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
Add .psqlrc
Modified Paths:
--------------
configs/trunk/setup-yang.bash
Added Paths:
-----------
configs/trunk/src/psqlrc
Modified: configs/trunk/setup-yang.bash
===================================================================
--- configs/trunk/setup-yang.bash 2013-03-23 19:53:30 UTC (rev 1847)
+++ configs/trunk/setup-yang.bash 2013-03-29 01:25:29 UTC (rev 1848)
@@ -26,6 +26,7 @@
install .lyx/bind/ lyx/bind/user.bind
install .matplotlib/matplotlibrc matplotlib/matplotlibrc
install .owl owl
+install .psqlrc psqlrc
install .pythonrc.py pythonrc.py
install .quiltrc quiltrc
install .screenrc screenrc
Added: configs/trunk/src/psqlrc
===================================================================
--- configs/trunk/src/psqlrc (rev 0)
+++ configs/trunk/src/psqlrc 2013-03-29 01:25:29 UTC (rev 1848)
@@ -0,0 +1 @@
+\pset null ¤
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2013-03-23 19:53:32
|
Revision: 1847
http://sourceforge.net/p/assorted/svn/1847
Author: yangzhang
Date: 2013-03-23 19:53:30 +0000 (Sat, 23 Mar 2013)
Log Message:
-----------
Add local class definition demo
Added Paths:
-----------
sandbox/trunk/src/coffee/localclass.coffee
Added: sandbox/trunk/src/coffee/localclass.coffee
===================================================================
--- sandbox/trunk/src/coffee/localclass.coffee (rev 0)
+++ sandbox/trunk/src/coffee/localclass.coffee 2013-03-23 19:53:30 UTC (rev 1847)
@@ -0,0 +1,31 @@
+# local classes are well behaved
+
+class C
+ constructor: ->
+ foo = 0
+ class S
+ constructor: -> foo += 1
+ @m = -> new S()
+ @get = -> foo
+
+class D
+ constructor: ->
+ foo = 0
+ class S
+ constructor: -> foo += 1
+ @m = -> new S()
+ @get = -> foo
+
+c = new C()
+d = new D()
+c.m()
+d.m()
+console.log(c.get()) # 1
+console.log(d.get()) # 1
+cc = new C()
+cc.m()
+console.log(c.get()) # 1
+console.log(cc.get()) # 1
+c.m()
+console.log(c.get()) # 2
+console.log(cc.get()) # 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2013-03-23 19:52:59
|
Revision: 1846
http://sourceforge.net/p/assorted/svn/1846
Author: yangzhang
Date: 2013-03-23 19:52:55 +0000 (Sat, 23 Mar 2013)
Log Message:
-----------
Demonstrate shared class var syntax
Added Paths:
-----------
sandbox/trunk/src/coffee/classvar.coffee
Added: sandbox/trunk/src/coffee/classvar.coffee
===================================================================
--- sandbox/trunk/src/coffee/classvar.coffee (rev 0)
+++ sandbox/trunk/src/coffee/classvar.coffee 2013-03-23 19:52:55 UTC (rev 1846)
@@ -0,0 +1,25 @@
+# watch out for this style of private variable - these are not instance vars but shared
+
+class C
+ foo = 0
+ m: -> foo += 1
+ get: -> foo
+
+class D
+ foo = 0
+ m: -> foo += 1
+ get: -> foo
+
+c = new C()
+d = new D()
+c.m()
+d.m()
+console.log(c.get()) # 1
+console.log(d.get()) # 1
+cc = new C()
+cc.m()
+console.log(c.get()) # 2
+console.log(cc.get()) # 2
+c.m()
+console.log(c.get()) # 3
+console.log(cc.get()) # 3
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2013-03-16 06:06:36
|
Revision: 1845
http://sourceforge.net/p/assorted/svn/1845
Author: yangzhang
Date: 2013-03-16 06:06:34 +0000 (Sat, 16 Mar 2013)
Log Message:
-----------
Demo coffeescript classes syntax
Added Paths:
-----------
sandbox/trunk/src/coffee/class.coffee
Added: sandbox/trunk/src/coffee/class.coffee
===================================================================
--- sandbox/trunk/src/coffee/class.coffee (rev 0)
+++ sandbox/trunk/src/coffee/class.coffee 2013-03-16 06:06:34 UTC (rev 1845)
@@ -0,0 +1,13 @@
+class C
+ constructor: ->
+ m: ->
+
+class D
+ a = 1
+
+class E
+ a = 1
+ constructor: ->
+ n: -> a
+ b = 2
+ m: -> a + b
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2013-03-12 23:22:45
|
Revision: 1844
http://assorted.svn.sourceforge.net/assorted/?rev=1844&view=rev
Author: yangzhang
Date: 2013-03-12 23:22:33 +0000 (Tue, 12 Mar 2013)
Log Message:
-----------
Work around keychain bug
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 2012-10-19 10:49:16 UTC (rev 1843)
+++ shell-tools/trunk/src/bash-commons/bashrc.bash 2013-03-12 23:22:33 UTC (rev 1844)
@@ -884,7 +884,12 @@
then keyfile=id_dsa
else keyfile=
fi
-if have keychain && [[ $keyfile ]]
+# Inherit to reuse gdm or agent-forwarding.
+# Unfortunately, broken in 2.7.1: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=502468
+#if have keychain && [[ $keyfile ]]
+#then eval `keychain --inherit any --eval --nogui $keychain_flags $keyfile 2> /dev/null`
+#fi
+if have keychain && [[ $keyfile ]] && [[ ! "$SSH_AUTH_SOCK" ]]
then eval `keychain --eval --nogui $keychain_flags $keyfile 2> /dev/null`
fi
@@ -915,3 +920,7 @@
if type virtualenvwrapper.sh &> /dev/null
then . virtualenvwrapper.sh
fi
+
+if [[ -f /etc/bash_completion.d/virtualenvwrapper ]]
+then . /etc/bash_completion.d/virtualenvwrapper
+fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-10-19 10:49:24
|
Revision: 1843
http://assorted.svn.sourceforge.net/assorted/?rev=1843&view=rev
Author: yangzhang
Date: 2012-10-19 10:49:16 +0000 (Fri, 19 Oct 2012)
Log Message:
-----------
Add Craigslist gig finder
Added Paths:
-----------
sandbox/trunk/src/one-off-scripts/craigslist-gig-finder/
sandbox/trunk/src/one-off-scripts/craigslist-gig-finder/go.bash
Added: sandbox/trunk/src/one-off-scripts/craigslist-gig-finder/go.bash
===================================================================
--- sandbox/trunk/src/one-off-scripts/craigslist-gig-finder/go.bash (rev 0)
+++ sandbox/trunk/src/one-off-scripts/craigslist-gig-finder/go.bash 2012-10-19 10:49:16 UTC (rev 1843)
@@ -0,0 +1,4 @@
+#for i in {1..9}; do echo "http://sfbay.craigslist.org/cpg/index${i}00.html" ; done | wget -i-
+#grep -h -P -o 'http://sfbay.craigslist.org/.*?\.html' index*.html | wget -nc -xi-
+grep -oPr 'Compensation:.*<' sfbay.craigslist.org/ | grep -P 'Compensation:.*\d{3}' | cut -f1 -d: | python go.py > results.txt
+grep -oPr 'Compensation:.*<' sfbay.craigslist.org/ | grep -iP 'Compensation:.*(well|high)' | cut -f1 -d: | python go.py > results.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-10-03 11:10:24
|
Revision: 1842
http://assorted.svn.sourceforge.net/assorted/?rev=1842&view=rev
Author: yangzhang
Date: 2012-10-03 11:10:14 +0000 (Wed, 03 Oct 2012)
Log Message:
-----------
Add html/js frames sandbox
Added Paths:
-----------
sandbox/trunk/src/web/frames/
sandbox/trunk/src/web/frames/Makefile
sandbox/trunk/src/web/frames/frame.jade
sandbox/trunk/src/web/frames/frames.jade
Added: sandbox/trunk/src/web/frames/Makefile
===================================================================
--- sandbox/trunk/src/web/frames/Makefile (rev 0)
+++ sandbox/trunk/src/web/frames/Makefile 2012-10-03 11:10:14 UTC (rev 1842)
@@ -0,0 +1,3 @@
+all: frames.html frame.html
+%.html: %.jade
+ jade $<
Added: sandbox/trunk/src/web/frames/frame.jade
===================================================================
--- sandbox/trunk/src/web/frames/frame.jade (rev 0)
+++ sandbox/trunk/src/web/frames/frame.jade 2012-10-03 11:10:14 UTC (rev 1842)
@@ -0,0 +1,14 @@
+doctype 5
+html
+ head
+ style
+ .foo { color: red; }
+ body
+ .foo Hi
+ script(type='text/javascript', src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js')
+ script(type='text/javascript')
+ function doit() {
+ console.log(getMatchedCSSRules===window.getMatchedCSSRules);
+ console.log(getMatchedCSSRules===document.defaultView.getMatchedCSSRules);
+ return getMatchedCSSRules($(".foo").get(0));
+ }
Added: sandbox/trunk/src/web/frames/frames.jade
===================================================================
--- sandbox/trunk/src/web/frames/frames.jade (rev 0)
+++ sandbox/trunk/src/web/frames/frames.jade 2012-10-03 11:10:14 UTC (rev 1842)
@@ -0,0 +1,20 @@
+doctype 5
+html
+ head
+ body
+ iframe(src='frame.html')
+ script(type='text/javascript', src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js')
+ :coffeescript
+ window.frame = null
+ # document onLoad doesn't wait for iframes
+ $ ->
+ # Wait for iframes to load
+ $('iframe').ready ->
+ # contentWindow same as (in the frame) document.defaultView
+ # document obtained via $('iframe').contents().get(0)
+ window.frame = $('iframe').get(0)
+ console.log(window.frame.contentWindow.doit())
+ console.log(window.frame.contentWindow.getMatchedCSSRules($('iframe').contents().find('.foo').get(0)))
+ console.log(window.getMatchedCSSRules($('iframe').contents().find('.foo').get(0)))
+
+ # FYI: objects in window are global to framed scripts as well
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-10-01 21:41:41
|
Revision: 1841
http://assorted.svn.sourceforge.net/assorted/?rev=1841&view=rev
Author: yangzhang
Date: 2012-10-01 21:41:35 +0000 (Mon, 01 Oct 2012)
Log Message:
-----------
Demo of greedy thread pool map
Added Paths:
-----------
sandbox/trunk/src/py/greedythreadpool.py
sandbox/trunk/src/py/thread_local_reuse.py
Removed Paths:
-------------
sandbox/trunk/src/py/multiprocessing.py
Added: sandbox/trunk/src/py/greedythreadpool.py
===================================================================
--- sandbox/trunk/src/py/greedythreadpool.py (rev 0)
+++ sandbox/trunk/src/py/greedythreadpool.py 2012-10-01 21:41:35 UTC (rev 1841)
@@ -0,0 +1,10 @@
+from __future__ import absolute_import
+import concurrent.futures as fut, time
+def f():
+ with fut.ThreadPoolExecutor(4) as tpe:
+ start = time.time()
+ list(tpe.map(g, [1,3,1,1]))
+ print time.time() - start
+def g(i):
+ time.sleep(i)
+f()
Deleted: sandbox/trunk/src/py/multiprocessing.py
===================================================================
--- sandbox/trunk/src/py/multiprocessing.py 2012-09-19 10:28:15 UTC (rev 1840)
+++ sandbox/trunk/src/py/multiprocessing.py 2012-10-01 21:41:35 UTC (rev 1841)
@@ -1,8 +0,0 @@
-import threading
-from concurrent.futures import *
-g=threading.local()
-def f(x):
- if not hasattr(g, 'f'):
- g.f = open('/tmp/foo','w')
- print >> g.f, x
-ProcessPoolExecutor(1).map(f, range(3))
Copied: sandbox/trunk/src/py/thread_local_reuse.py (from rev 1837, sandbox/trunk/src/py/multiprocessing.py)
===================================================================
--- sandbox/trunk/src/py/thread_local_reuse.py (rev 0)
+++ sandbox/trunk/src/py/thread_local_reuse.py 2012-10-01 21:41:35 UTC (rev 1841)
@@ -0,0 +1,8 @@
+import threading
+from concurrent.futures import *
+g=threading.local()
+def f(x):
+ if not hasattr(g, 'f'):
+ g.f = open('/tmp/foo','w')
+ print >> g.f, x
+ProcessPoolExecutor(1).map(f, range(3))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-09-19 10:28:26
|
Revision: 1840
http://assorted.svn.sourceforge.net/assorted/?rev=1840&view=rev
Author: yangzhang
Date: 2012-09-19 10:28:15 +0000 (Wed, 19 Sep 2012)
Log Message:
-----------
Add coffeescript scope demo
Added Paths:
-----------
sandbox/trunk/src/coffee/
sandbox/trunk/src/coffee/scope.coffee
Added: sandbox/trunk/src/coffee/scope.coffee
===================================================================
--- sandbox/trunk/src/coffee/scope.coffee (rev 0)
+++ sandbox/trunk/src/coffee/scope.coffee 2012-09-19 10:28:15 UTC (rev 1840)
@@ -0,0 +1,10 @@
+x = 0
+# binding via args doesn't affect outer scope
+f = (x) ->
+f(1)
+console.log(x)
+# binding as local var does affect outer scope
+f = ->
+ x = 1
+f()
+console.log(x)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-09-08 01:13:17
|
Revision: 1839
http://assorted.svn.sourceforge.net/assorted/?rev=1839&view=rev
Author: yangzhang
Date: 2012-09-08 01:13:11 +0000 (Sat, 08 Sep 2012)
Log Message:
-----------
Add pg-for-all
Modified Paths:
--------------
shell-tools/trunk/src/bash-commons/common.bash
Modified: shell-tools/trunk/src/bash-commons/common.bash
===================================================================
--- shell-tools/trunk/src/bash-commons/common.bash 2012-08-15 17:22:44 UTC (rev 1838)
+++ shell-tools/trunk/src/bash-commons/common.bash 2012-09-08 01:13:11 UTC (rev 1839)
@@ -672,6 +672,28 @@
psql
}
+# Outputs a query that selects all schema.table names.
+#
+# Usage example:
+# pg-for-all tables |
+# sudo -u postgres psql pod |
+# xargs -I_ echo 'alter table _ owner to joe;' |
+# sudo -u postgres psql pod
+pg-for-all() {
+ local type=$1 where=${2:-true}
+ case $type in
+ tables )
+ echo "
+ select schemaname || '.' || tablename
+ from pg_tables
+ where $where
+ and schemaname != 'pg_catalog'
+ and schemaname != 'information_schema'
+ order by 1;
+ " ;;
+ esac
+}
+
# Resume SCP; from <http://joen.dk/wordpress/?p=34>
scp-resume() {
rsync --partial --progress "$@"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-08-15 17:22:50
|
Revision: 1838
http://assorted.svn.sourceforge.net/assorted/?rev=1838&view=rev
Author: yangzhang
Date: 2012-08-15 17:22:44 +0000 (Wed, 15 Aug 2012)
Log Message:
-----------
Add old missing TopCoder stabs
Added Paths:
-----------
problems/topcoder/BinaryCode/BinaryCode3.cpp
problems/topcoder/BusinessTasks/BusinessTasks2.cpp
Added: problems/topcoder/BinaryCode/BinaryCode3.cpp
===================================================================
--- problems/topcoder/BinaryCode/BinaryCode3.cpp (rev 0)
+++ problems/topcoder/BinaryCode/BinaryCode3.cpp 2012-08-15 17:22:44 UTC (rev 1838)
@@ -0,0 +1,246 @@
+// vim:noet:sw=2:ts=2
+
+// BEGIN CUT HERE
+#if 0
+// PROBLEM STATEMENT
+// Let's say you have a binary string such as the following:
+
+011100011
+
+One way to encrypt this string is to add to each digit the sum of its adjacent digits. For example, the above string would become:
+
+123210122
+
+In particular, if P is the original string, and Q is the encrypted string, then Q[i] = P[i-1] + P[i] + P[i+1] for all digit positions i. Characters off the left and right edges of the string are treated as zeroes.
+
+An encrypted string given to you in this format can be decoded as follows (using 123210122 as an example):
+
+Assume P[0] = 0.
+Because Q[0] = P[0] + P[1] = 0 + P[1] = 1, we know that P[1] = 1.
+Because Q[1] = P[0] + P[1] + P[2] = 0 + 1 + P[2] = 2, we know that P[2] = 1.
+Because Q[2] = P[1] + P[2] + P[3] = 1 + 1 + P[3] = 3, we know that P[3] = 1.
+Repeating these steps gives us P[4] = 0, P[5] = 0, P[6] = 0, P[7] = 1, and P[8] = 1.
+We check our work by noting that Q[8] = P[7] + P[8] = 1 + 1 = 2. Since this equation works out, we are finished, and we have recovered one possible original string.
+
+Now we repeat the process, assuming the opposite about P[0]:
+
+Assume P[0] = 1.
+Because Q[0] = P[0] + P[1] = 1 + P[1] = 0, we know that P[1] = 0.
+Because Q[1] = P[0] + P[1] + P[2] = 1 + 0 + P[2] = 2, we know that P[2] = 1.
+Now note that Q[2] = P[1] + P[2] + P[3] = 0 + 1 + P[3] = 3, which leads us to the conclusion that P[3] = 2. However, this violates the fact that each character in the original string must be '0' or '1'. Therefore, there exists no such original string P where the first digit is '1'.
+
+Note that this algorithm produces at most two decodings for any given encrypted string. There can never be more than one possible way to decode a string once the first binary digit is set.
+
+Given a string message, containing the encrypted string, return a vector <string> with exactly two elements. The first element should contain the decrypted string assuming the first character is '0'; the second element should assume the first character is '1'. If one of the tests fails, return the string "NONE" in its place. For the above example, you should return {"011100011", "NONE"}.
+
+DEFINITION
+Class:BinaryCode
+Method:decode
+Parameters:string
+Returns:vector <string>
+Method signature:vector <string> decode(string message)
+
+
+CONSTRAINTS
+-message will contain between 1 and 50 characters, inclusive.
+-Each character in message will be either '0', '1', '2', or '3'.
+
+
+EXAMPLES
+
+0)
+"123210122"
+
+Returns: { "011100011", "NONE" }
+
+The example from above.
+
+1)
+"11"
+
+Returns: { "01", "10" }
+
+We know that one of the digits must be '1', and the other must be '0'. We return both cases.
+
+2)
+"22111"
+
+Returns: { "NONE", "11001" }
+
+Since the first digit of the encrypted string is '2', the first two digits of the original string must be '1'. Our test fails when we try to assume that P[0] = 0.
+
+3)
+"123210120"
+
+Returns: { "NONE", "NONE" }
+
+This is the same as the first example, but the rightmost digit has been changed to something inconsistent with the rest of the original string. No solutions are possible.
+
+4)
+"3"
+
+Returns: { "NONE", "NONE" }
+
+5)
+"12221112222221112221111111112221111"
+
+Returns: { "01101001101101001101001001001101001", "10110010110110010110010010010110010" }
+
+#endif
+// END CUT HERE
+
+//#line 93 "BinaryCode.cpp"
+#include <algorithm>
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <queue>
+#include <set>
+#include <sstream>
+#include <string>
+#include <vector>
+using namespace std;
+
+// BEGIN CUT HERE
+#define ARRSIZE(x) (sizeof(x)/sizeof(x[0]))
+
+template<typename T> void print( T a ) {
+ cerr << a;
+}
+static void print( long long a ) {
+ cerr << a << "L";
+}
+static void print( string a ) {
+ cerr << '"' << a << '"';
+}
+template<typename T> void print( vector<T> a ) {
+ cerr << "{";
+ for ( int i = 0 ; i != a.size() ; i++ ) {
+ if ( i != 0 ) cerr << ", ";
+ print( a[i] );
+ }
+ cerr << "}" << endl;
+}
+template<typename T> void eq( int n, T have, T need ) {
+ if ( have == need ) {
+ cerr << "Case " << n << " passed." << endl;
+ } else {
+ cerr << "Case " << n << " failed: expected ";
+ print( need );
+ cerr << " received ";
+ print( have );
+ cerr << "." << endl;
+ }
+}
+template<typename T> void eq( int n, vector<T> have, vector<T> need ) {
+ if( have.size() != need.size() ) {
+ cerr << "Case " << n << " failed: returned " << have.size() << " elements; expected " << need.size() << " elements." << endl;
+ cerr << " have: "; print( have );
+ cerr << " need: "; print( need );
+ return;
+ }
+ for( size_t i= 0; i < have.size(); i++ ) {
+ if( have[i] != need[i] ) {
+ cerr << "Case " << n << " failed. Expected and returned array differ in position " << i << "." << endl;
+ cerr << " have: "; print( have );
+ cerr << " need: "; print( need );
+ return;
+ }
+ }
+ cerr << "Case " << n << " passed." << endl;
+}
+static void eq( int n, string have, string need ) {
+ if ( have == need ) {
+ cerr << "Case " << n << " passed." << endl;
+ } else {
+ cerr << "Case " << n << " failed: expected ";
+ print( need );
+ cerr << " received ";
+ print( have );
+ cerr << "." << endl;
+ }
+}
+// END CUT HERE
+
+#define ARRSIZE(x) (sizeof(x)/sizeof(x[0]))
+
+vector<string> split( const string& s, const string& delim =" " ) {
+ vector<string> res;
+ string t;
+ for ( int i = 0 ; i != s.size() ; i++ ) {
+ if ( delim.find( s[i] ) != string::npos ) {
+ if ( !t.empty() ) {
+ res.push_back( t );
+ t = "";
+ }
+ } else {
+ t += s[i];
+ }
+ }
+ if ( !t.empty() ) {
+ res.push_back(t);
+ }
+ return res;
+}
+
+vector<int> splitInt( const string& s, const string& delim =" " ) {
+ vector<string> tok = split( s, delim );
+ vector<int> res;
+ for ( int i = 0 ; i != tok.size(); i++ )
+ res.push_back( atoi( tok[i].c_str() ) );
+ return res;
+}
+
+class BinaryCode {
+ public:
+ vector <string> decode(string message) {
+ vector <string> res;
+ return res;
+ }
+};
+
+// BEGIN CUT HERE
+int main() {
+ {
+ string retrunValueARRAY[] = { "011100011", "NONE" };
+ vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
+ BinaryCode theObject;
+ eq(0, theObject.decode("123210122"),retrunValue);
+ }
+ {
+ string retrunValueARRAY[] = { "01", "10" };
+ vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
+ BinaryCode theObject;
+ eq(1, theObject.decode("11"),retrunValue);
+ }
+ {
+ string retrunValueARRAY[] = { "NONE", "11001" };
+ vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
+ BinaryCode theObject;
+ eq(2, theObject.decode("22111"),retrunValue);
+ }
+ {
+ string retrunValueARRAY[] = { "NONE", "NONE" };
+ vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
+ BinaryCode theObject;
+ eq(3, theObject.decode("123210120"),retrunValue);
+ }
+ {
+ string retrunValueARRAY[] = { "NONE", "NONE" };
+ vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
+ BinaryCode theObject;
+ eq(4, theObject.decode("3"),retrunValue);
+ }
+ {
+ string retrunValueARRAY[] = { "01101001101101001101001001001101001", "10110010110110010110010010010110010" };
+ vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
+ BinaryCode theObject;
+ eq(5, theObject.decode("12221112222221112221111111112221111"),retrunValue);
+ }
+ cin.get();
+ return 0;
+}
+// END CUT HERE
Added: problems/topcoder/BusinessTasks/BusinessTasks2.cpp
===================================================================
--- problems/topcoder/BusinessTasks/BusinessTasks2.cpp (rev 0)
+++ problems/topcoder/BusinessTasks/BusinessTasks2.cpp 2012-08-15 17:22:44 UTC (rev 1838)
@@ -0,0 +1,238 @@
+// vim:noet:sw=2:ts=2
+
+// BEGIN CUT HERE
+#if 0
+// PROBLEM STATEMENT
+// A busy businessman has a number of equally important tasks which he must accomplish. To decide which of the tasks to perform first, he performs the following operation.
+
+He writes down all his tasks in the form of a circular list, so the first task is adjacent to the last task. He then thinks of a positive number. This number is the random seed, which he calls n. Starting with the first task, he moves clockwise (from element 1 in the list to element 2 in the list and so on), counting from 1 to n. When his count reaches n, he removes that task from the list and starts counting from the next available task. He repeats this procedure until one task remains. It is this last task that he chooses to execute.
+
+Given a vector <string> list representing the tasks and an int n, return the task which the businessman chooses to execute.
+
+
+DEFINITION
+Class:BusinessTasks
+Method:getTask
+Parameters:vector <string>, int
+Returns:string
+Method signature:string getTask(vector <string> list, int n)
+
+
+CONSTRAINTS
+-list will contain between 2 and 50 elements inclusive.
+-Each element in list will contain between 1 and 50 characters inclusive.
+-Each element in list will contain only characters 'a'-'z'.
+-n will be between 1 and 10000000 inclusive.
+
+
+EXAMPLES
+
+0)
+{"a","b","c","d"}
+2
+
+Returns: "a"
+
+We start counting from a. So a is 1, b is 2. We remove b, so list is now {a,c,d}. We continue from c. So c is 1, d is 2. We remove d, so list is now {a,c}. We continue from a. So a is 1, c is 2. We remove c, and now we are left with the last task a.
+
+1)
+{"a","b","c","d","e"}
+3
+
+Returns: "d"
+
+We start counting from a. So a is 1, b is 2, c is 3. We remove c, now list = {a,b,d,e}. We continue from d. So d is 1, e is 2, a is 3. We remove a, now list = {b,d,e}. We continue from b. So b is 1, d is 2, e is 3. We remove e, now list = {b,d}. We continue from b. So b is 1, d is 2 and finally b is 3. We remove b, and now we are left with just one task d.
+
+2)
+{"alpha","beta","gamma","delta","epsilon"}
+1
+
+Returns: "epsilon"
+
+3)
+{"a","b"}
+1000
+
+Returns: "a"
+
+4)
+{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t",
+"u","v","w","x","y","z"}
+17
+
+Returns: "n"
+
+5)
+{"zlqamum","yjsrpybmq","tjllfea","fxjqzznvg","nvhekxr","am","skmazcey","piklp",
+"olcqvhg","dnpo","bhcfc","y","h","fj","bjeoaxglt","oafduixsz","kmtbaxu",
+"qgcxjbfx","my","mlhy","bt","bo","q"}
+9000000
+
+Returns: "fxjqzznvg"
+
+#endif
+// END CUT HERE
+
+//#line 77 "BusinessTasks.cpp"
+#include <algorithm>
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <queue>
+#include <set>
+#include <sstream>
+#include <string>
+#include <vector>
+using namespace std;
+
+// BEGIN CUT HERE
+#define ARRSIZE(x) (sizeof(x)/sizeof(x[0]))
+
+template<typename T> void print( T a ) {
+ cerr << a;
+}
+static void print( long long a ) {
+ cerr << a << "L";
+}
+static void print( string a ) {
+ cerr << '"' << a << '"';
+}
+template<typename T> void print( vector<T> a ) {
+ cerr << "{";
+ for ( int i = 0 ; i != a.size() ; i++ ) {
+ if ( i != 0 ) cerr << ", ";
+ print( a[i] );
+ }
+ cerr << "}" << endl;
+}
+template<typename T> void eq( int n, T have, T need ) {
+ if ( have == need ) {
+ cerr << "Case " << n << " passed." << endl;
+ } else {
+ cerr << "Case " << n << " failed: expected ";
+ print( need );
+ cerr << " received ";
+ print( have );
+ cerr << "." << endl;
+ }
+}
+template<typename T> void eq( int n, vector<T> have, vector<T> need ) {
+ if( have.size() != need.size() ) {
+ cerr << "Case " << n << " failed: returned " << have.size() << " elements; expected " << need.size() << " elements." << endl;
+ cerr << " have: "; print( have );
+ cerr << " need: "; print( need );
+ return;
+ }
+ for( size_t i= 0; i < have.size(); i++ ) {
+ if( have[i] != need[i] ) {
+ cerr << "Case " << n << " failed. Expected and returned array differ in position " << i << "." << endl;
+ cerr << " have: "; print( have );
+ cerr << " need: "; print( need );
+ return;
+ }
+ }
+ cerr << "Case " << n << " passed." << endl;
+}
+static void eq( int n, string have, string need ) {
+ if ( have == need ) {
+ cerr << "Case " << n << " passed." << endl;
+ } else {
+ cerr << "Case " << n << " failed: expected ";
+ print( need );
+ cerr << " received ";
+ print( have );
+ cerr << "." << endl;
+ }
+}
+// END CUT HERE
+
+#define ARRSIZE(x) (sizeof(x)/sizeof(x[0]))
+
+vector<string> split( const string& s, const string& delim =" " ) {
+ vector<string> res;
+ string t;
+ for ( int i = 0 ; i != s.size() ; i++ ) {
+ if ( delim.find( s[i] ) != string::npos ) {
+ if ( !t.empty() ) {
+ res.push_back( t );
+ t = "";
+ }
+ } else {
+ t += s[i];
+ }
+ }
+ if ( !t.empty() ) {
+ res.push_back(t);
+ }
+ return res;
+}
+
+vector<int> splitInt( const string& s, const string& delim =" " ) {
+ vector<string> tok = split( s, delim );
+ vector<int> res;
+ for ( int i = 0 ; i != tok.size(); i++ )
+ res.push_back( atoi( tok[i].c_str() ) );
+ return res;
+}
+
+class BusinessTasks {
+ public:
+ string getTask(vector <string> list, int n) {
+ int i = 0;
+ while (list.size() > 1) {
+ i = (i - 1 + n) % list.size();
+ list.erase(list.begin() + i);
+ }
+ string res = list[0];
+ return res;
+ }
+};
+
+// BEGIN CUT HERE
+int main() {
+ {
+ string listARRAY[] = {"a","b","c","d"};
+ vector <string> list( listARRAY, listARRAY+ARRSIZE(listARRAY) );
+ BusinessTasks theObject;
+ eq(0, theObject.getTask(list, 2),"a");
+ }
+ {
+ string listARRAY[] = {"a","b","c","d","e"};
+ vector <string> list( listARRAY, listARRAY+ARRSIZE(listARRAY) );
+ BusinessTasks theObject;
+ eq(1, theObject.getTask(list, 3),"d");
+ }
+ {
+ string listARRAY[] = {"alpha","beta","gamma","delta","epsilon"};
+ vector <string> list( listARRAY, listARRAY+ARRSIZE(listARRAY) );
+ BusinessTasks theObject;
+ eq(2, theObject.getTask(list, 1),"epsilon");
+ }
+ {
+ string listARRAY[] = {"a","b"};
+ vector <string> list( listARRAY, listARRAY+ARRSIZE(listARRAY) );
+ BusinessTasks theObject;
+ eq(3, theObject.getTask(list, 1000),"a");
+ }
+ {
+ string listARRAY[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t",
+ "u","v","w","x","y","z"};
+ vector <string> list( listARRAY, listARRAY+ARRSIZE(listARRAY) );
+ BusinessTasks theObject;
+ eq(4, theObject.getTask(list, 17),"n");
+ }
+ {
+ string listARRAY[] = {"zlqamum","yjsrpybmq","tjllfea","fxjqzznvg","nvhekxr","am","skmazcey","piklp",
+ "olcqvhg","dnpo","bhcfc","y","h","fj","bjeoaxglt","oafduixsz","kmtbaxu",
+ "qgcxjbfx","my","mlhy","bt","bo","q"};
+ vector <string> list( listARRAY, listARRAY+ARRSIZE(listARRAY) );
+ BusinessTasks theObject;
+ eq(5, theObject.getTask(list, 9000000),"fxjqzznvg");
+ }
+ cin.get();
+ return 0;
+}
+// END CUT HERE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-08-09 03:51:25
|
Revision: 1837
http://assorted.svn.sourceforge.net/assorted/?rev=1837&view=rev
Author: yangzhang
Date: 2012-08-09 03:51:19 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Add demo of distribute finding source packages
Added Paths:
-----------
sandbox/trunk/src/py/distribute/
sandbox/trunk/src/py/distribute/setup.py
sandbox/trunk/src/py/distribute/src/
sandbox/trunk/src/py/distribute/src/foo/
sandbox/trunk/src/py/distribute/src/foo/__init__.py
sandbox/trunk/src/py/distribute/src2/
sandbox/trunk/src/py/distribute/src2/bar.py
sandbox/trunk/src/py/distribute/src2/testapp.egg-info/
sandbox/trunk/src/py/distribute/src2/testapp.egg-info/PKG-INFO
sandbox/trunk/src/py/distribute/src2/testapp.egg-info/SOURCES.txt
sandbox/trunk/src/py/distribute/src2/testapp.egg-info/dependency_links.txt
sandbox/trunk/src/py/distribute/src2/testapp.egg-info/top_level.txt
Added: sandbox/trunk/src/py/distribute/setup.py
===================================================================
--- sandbox/trunk/src/py/distribute/setup.py (rev 0)
+++ sandbox/trunk/src/py/distribute/setup.py 2012-08-09 03:51:19 UTC (rev 1837)
@@ -0,0 +1,13 @@
+from setuptools import setup, find_packages
+
+setup(
+ name = 'testapp',
+ version = '0.1',
+ packages = find_packages('src'),
+ py_modules = ['bar'],
+ package_dir = {
+ 'foo': 'src/foo',
+ '': 'src2',
+ },
+)
+
Added: sandbox/trunk/src/py/distribute/src/foo/__init__.py
===================================================================
Added: sandbox/trunk/src/py/distribute/src2/bar.py
===================================================================
Added: sandbox/trunk/src/py/distribute/src2/testapp.egg-info/PKG-INFO
===================================================================
--- sandbox/trunk/src/py/distribute/src2/testapp.egg-info/PKG-INFO (rev 0)
+++ sandbox/trunk/src/py/distribute/src2/testapp.egg-info/PKG-INFO 2012-08-09 03:51:19 UTC (rev 1837)
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: testapp
+Version: 0.1
+Summary: UNKNOWN
+Home-page: UNKNOWN
+Author: UNKNOWN
+Author-email: UNKNOWN
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
Added: sandbox/trunk/src/py/distribute/src2/testapp.egg-info/SOURCES.txt
===================================================================
--- sandbox/trunk/src/py/distribute/src2/testapp.egg-info/SOURCES.txt (rev 0)
+++ sandbox/trunk/src/py/distribute/src2/testapp.egg-info/SOURCES.txt 2012-08-09 03:51:19 UTC (rev 1837)
@@ -0,0 +1,6 @@
+src/foo/__init__.py
+src2/bar.py
+src2/testapp.egg-info/PKG-INFO
+src2/testapp.egg-info/SOURCES.txt
+src2/testapp.egg-info/dependency_links.txt
+src2/testapp.egg-info/top_level.txt
\ No newline at end of file
Added: sandbox/trunk/src/py/distribute/src2/testapp.egg-info/dependency_links.txt
===================================================================
--- sandbox/trunk/src/py/distribute/src2/testapp.egg-info/dependency_links.txt (rev 0)
+++ sandbox/trunk/src/py/distribute/src2/testapp.egg-info/dependency_links.txt 2012-08-09 03:51:19 UTC (rev 1837)
@@ -0,0 +1 @@
+
Added: sandbox/trunk/src/py/distribute/src2/testapp.egg-info/top_level.txt
===================================================================
--- sandbox/trunk/src/py/distribute/src2/testapp.egg-info/top_level.txt (rev 0)
+++ sandbox/trunk/src/py/distribute/src2/testapp.egg-info/top_level.txt 2012-08-09 03:51:19 UTC (rev 1837)
@@ -0,0 +1,2 @@
+foo
+bar
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-08-09 03:50:20
|
Revision: 1836
http://assorted.svn.sourceforge.net/assorted/?rev=1836&view=rev
Author: yangzhang
Date: 2012-08-09 03:50:13 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Add multiprocessing bug demo
Added Paths:
-----------
sandbox/trunk/src/py/multiprocessing.py
Added: sandbox/trunk/src/py/multiprocessing.py
===================================================================
--- sandbox/trunk/src/py/multiprocessing.py (rev 0)
+++ sandbox/trunk/src/py/multiprocessing.py 2012-08-09 03:50:13 UTC (rev 1836)
@@ -0,0 +1,8 @@
+import threading
+from concurrent.futures import *
+g=threading.local()
+def f(x):
+ if not hasattr(g, 'f'):
+ g.f = open('/tmp/foo','w')
+ print >> g.f, x
+ProcessPoolExecutor(1).map(f, range(3))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-08-09 03:48:09
|
Revision: 1835
http://assorted.svn.sourceforge.net/assorted/?rev=1835&view=rev
Author: yangzhang
Date: 2012-08-09 03:48:03 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Enable HISTCONTROL ignorespace
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 2012-08-09 03:46:46 UTC (rev 1834)
+++ shell-tools/trunk/src/bash-commons/bashrc.bash 2012-08-09 03:48:03 UTC (rev 1835)
@@ -166,7 +166,7 @@
# bash
# don't put duplicate lines in the history
-export HISTCONTROL=ignoredups
+export HISTCONTROL=ignoredups:ignorespace
export HISTFILESIZE=10000000
export HISTSIZE=10000000
shopt -s checkwinsize cdable_vars
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-08-09 03:46:52
|
Revision: 1834
http://assorted.svn.sourceforge.net/assorted/?rev=1834&view=rev
Author: yangzhang
Date: 2012-08-09 03:46:46 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Fix pg-space handling of big sizes
Modified Paths:
--------------
shell-tools/trunk/src/bash-commons/common.bash
Modified: shell-tools/trunk/src/bash-commons/common.bash
===================================================================
--- shell-tools/trunk/src/bash-commons/common.bash 2012-07-14 05:49:41 UTC (rev 1833)
+++ shell-tools/trunk/src/bash-commons/common.bash 2012-08-09 03:46:46 UTC (rev 1834)
@@ -744,7 +744,7 @@
select
_schema,
sum(bytes) as bytes,
- lpad(pg_size_pretty(sum(bytes)::int), 9) as size,
+ lpad(pg_size_pretty(sum(bytes)::bigint), 12) as size,
sum(pct) as pct
from base
group by _schema
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-07-14 05:49:47
|
Revision: 1833
http://assorted.svn.sourceforge.net/assorted/?rev=1833&view=rev
Author: yangzhang
Date: 2012-07-14 05:49:41 +0000 (Sat, 14 Jul 2012)
Log Message:
-----------
Adjust Twitter widget size
Modified Paths:
--------------
personal-site/trunk/README
Modified: personal-site/trunk/README
===================================================================
--- personal-site/trunk/README 2012-07-14 05:47:51 UTC (rev 1832)
+++ personal-site/trunk/README 2012-07-14 05:49:41 UTC (rev 1833)
@@ -82,7 +82,7 @@
the search form:
<?php get_search_form(); ?>
- <div style='position:absolute;right:7.6%;top:7em'><a href="https://twitter.com/yaaang" class="twitter-follow-button" data-show-count="true" data-size="large" data-width="240px" data-align="right">Follow @yaaang</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
+ <div style='position:absolute;right:7.6%;top:7em'><a href="https://twitter.com/yaaang" class="twitter-follow-button" data-show-count="true" data-size="large" data-width="260px" data-align="right">Follow @yaaang</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
<?php endif; ?>
Apache
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-07-14 05:47:58
|
Revision: 1832
http://assorted.svn.sourceforge.net/assorted/?rev=1832&view=rev
Author: yangzhang
Date: 2012-07-14 05:47:51 +0000 (Sat, 14 Jul 2012)
Log Message:
-----------
Add 7zc, 7zcd, 7zcdf
Modified Paths:
--------------
shell-tools/trunk/src/bash-commons/common.bash
Modified: shell-tools/trunk/src/bash-commons/common.bash
===================================================================
--- shell-tools/trunk/src/bash-commons/common.bash 2012-07-13 21:55:38 UTC (rev 1831)
+++ shell-tools/trunk/src/bash-commons/common.bash 2012-07-14 05:47:51 UTC (rev 1832)
@@ -799,6 +799,25 @@
done
}
+7zc() {
+ for i in "$@" ; do
+ local j="$( echo "$i" | sed 's|/\+$||' ).7z"
+ 7z a -mx=9 -m0=lzma2 -mmt=4 "$j" "$i"
+ done
+}
+
+7zcd() {
+ for i in "$@" ; do
+ 7zc "$i" && rm -r "$i"
+ done
+}
+
+7zcdf() {
+ for i in "$@" ; do
+ 7zc "$i" && rm -rf "$i"
+ 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.
|
|
From: <yan...@us...> - 2012-07-13 21:55:45
|
Revision: 1831
http://assorted.svn.sourceforge.net/assorted/?rev=1831&view=rev
Author: yangzhang
Date: 2012-07-13 21:55:38 +0000 (Fri, 13 Jul 2012)
Log Message:
-----------
Add mount-ecryptfs
Modified Paths:
--------------
shell-tools/trunk/src/bash-commons/common.bash
Modified: shell-tools/trunk/src/bash-commons/common.bash
===================================================================
--- shell-tools/trunk/src/bash-commons/common.bash 2012-07-10 00:52:16 UTC (rev 1830)
+++ shell-tools/trunk/src/bash-commons/common.bash 2012-07-13 21:55:38 UTC (rev 1831)
@@ -786,6 +786,12 @@
eval "$(keychain --eval --timeout $minutes id_rsa)"
}
+mount-ecryptfs() {
+ local dir="$1"
+ sudo mount -t ecryptfs "$dir"{,} -o \
+ ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=n,ecryptfs_enable_filename_crypto=n
+}
+
wait-idle() {
while (( $( top -b -n 2 | grep ^Cpu | tail -1 |
sed 's/.* \([[:digit:]]*\)\.[[:digit:]]*%id.*/\1/g' ) < 50 ))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-07-10 00:52:22
|
Revision: 1830
http://assorted.svn.sourceforge.net/assorted/?rev=1830&view=rev
Author: yangzhang
Date: 2012-07-10 00:52:16 +0000 (Tue, 10 Jul 2012)
Log Message:
-----------
Add simple-date
Modified Paths:
--------------
shell-tools/trunk/src/bash-commons/common.bash
Modified: shell-tools/trunk/src/bash-commons/common.bash
===================================================================
--- shell-tools/trunk/src/bash-commons/common.bash 2012-05-17 19:30:43 UTC (rev 1829)
+++ shell-tools/trunk/src/bash-commons/common.bash 2012-07-10 00:52:16 UTC (rev 1830)
@@ -281,6 +281,10 @@
date +%Y%m%d
}
+simple-date() {
+ date +%Y-%m-%d
+}
+
# from http://joen.dk/wordpress/?p=34
rsyncp() {
rsync -e ssh -P "$@"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-05-17 19:30:49
|
Revision: 1829
http://assorted.svn.sourceforge.net/assorted/?rev=1829&view=rev
Author: yangzhang
Date: 2012-05-17 19:30:43 +0000 (Thu, 17 May 2012)
Log Message:
-----------
Add enrich-collections sandbox
Added Paths:
-----------
sandbox/trunk/src/scala/EnrichCollections.scala
Added: sandbox/trunk/src/scala/EnrichCollections.scala
===================================================================
--- sandbox/trunk/src/scala/EnrichCollections.scala (rev 0)
+++ sandbox/trunk/src/scala/EnrichCollections.scala 2012-05-17 19:30:43 UTC (rev 1829)
@@ -0,0 +1,44 @@
+// For playing with Miles Sabin's 2.10 commit in 2.9.
+// https://github.com/scala/scala/commit/25d1f6d0cb720129b5ac647542cfca3d18304ae2
+
+import scala.collection._
+import scala.collection.generic._
+
+object GenTraversableLike {
+ type HasElem[Repr, A] = Repr => GenTraversableLike[A, Repr]
+ trait FromRepr[Repr] {
+ type A
+ val hasElem: HasElem[Repr, A]
+ }
+ /** Manufacture a conversion from collection representation type `Repr` to
+ * its corresponding `GenTraversableLike` given an implicitly available
+ * instance of `FromRepr[Repr]`.
+ * @see [[scala.collection.generic.FromRepr]]
+ */
+ implicit def fromRepr[Repr](implicit fr : FromRepr[Repr]) = fr.hasElem
+
+ implicit val stringFromRepr : FromRepr[String] { type A = Char } = new FromRepr[String] {
+ type A = Char
+ val hasElem = implicitly[HasElem[String, Char]]
+ }
+
+ implicit def genTraversableLikeFromRepr[C[_], A0]
+ (implicit hasElem0: HasElem[C[A0], A0]) : FromRepr[C[A0]] { type A = A0 } = new FromRepr[C[A0]] {
+ type A = A0
+ val hasElem = hasElem0
+ }
+
+
+ def typed[T](t : => T) {}
+
+ class FilterMapImpl[A, Repr](val r : Repr)(implicit hasElem : HasElem[Repr, A]) {
+ def filterMap[B, That](f : A => Option[B])(implicit cbf : CanBuildFrom[Repr, B, That]) : That = r.flatMap(f(_).toSeq)
+ }
+
+ implicit def filterMap[Repr : FromRepr](r : Repr) = new FilterMapImpl(r)
+
+ val s = "Hello World"
+ val fms1 = s.filterMap(c => if(c >= 'A' && c <= 'Z') Some(c) else None)
+ typed[String](fms1)
+ println(fms1)
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yan...@us...> - 2012-03-15 22:17:57
|
Revision: 1828
http://assorted.svn.sourceforge.net/assorted/?rev=1828&view=rev
Author: yangzhang
Date: 2012-03-15 22:17:51 +0000 (Thu, 15 Mar 2012)
Log Message:
-----------
Add clean-swp
Modified Paths:
--------------
shell-tools/trunk/README
Added Paths:
-----------
shell-tools/trunk/src/clean-swp.bash
Modified: shell-tools/trunk/README
===================================================================
--- shell-tools/trunk/README 2012-02-10 09:05:45 UTC (rev 1827)
+++ shell-tools/trunk/README 2012-03-15 22:17:51 UTC (rev 1828)
@@ -52,6 +52,9 @@
from a directory tree. implementation,
[HSH]
+`clean-swp` Clean up vim swap files, removing any redundant bash, vim
+ files and vimdiffing the rest.
+
`clobber- Only replace an existing file if the contents Python
if-diff` actually changed. Useful in Makefiles.
Added: shell-tools/trunk/src/clean-swp.bash
===================================================================
--- shell-tools/trunk/src/clean-swp.bash (rev 0)
+++ shell-tools/trunk/src/clean-swp.bash 2012-03-15 22:17:51 UTC (rev 1828)
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+# <http://stackoverflow.com/a/5826793/43118>
+
+IFS=$'\n'
+
+TMPDIR=$(mktemp -d) || exit 1
+RECTXT="$TMPDIR/vim.recovery.$USER.txt"
+RECFN="$TMPDIR/vim.recovery.$USER.fn"
+trap 'rm -f "$RECTXT" "$RECFN"; rmdir "$TMPDIR"' 0 1 2 3 15
+for q in "$@"; do
+ echo $q
+ [[ -f $q ]] || continue
+ rm -f "$RECTXT" "$RECFN"
+ vim -X -r "$q" \
+ -c "w! $RECTXT" \
+ -c "let fn=expand('%')" \
+ -c "new $RECFN" \
+ -c "exec setline( 1, fn )" \
+ -c w\! \
+ -c "qa"
+ if [[ ! -f $RECFN ]]; then
+ echo "nothing to recover from $q"
+ rm -f "$q"
+ continue
+ fi
+ CRNT="$(cat $RECFN)"
+ if [ "$CRNT" = "$RECTXT" ]; then
+ echo "Can't find original file. Press enter to open vim so you can save the file. The swap file will be deleted afterward!"
+ read
+ vim "$CRNT"
+ rm -f "$q"
+ else if diff --strip-trailing-cr --brief "$CRNT" "$RECTXT"; then
+ echo "Removing redundant $q"
+ echo " for $CRNT"
+ rm -f "$q"
+ else
+ echo $q contains changes, or there may be no original saved file
+ vim -n -d "$CRNT" "$RECTXT"
+ rm -i "$q" || exit
+ fi
+ fi
+done
Property changes on: shell-tools/trunk/src/clean-swp.bash
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|