209 karma · joined November 10, 2013
vim -x scp://.../...
autoload zmv
zmv '(*).baz' '$1.bar'[1] https://github.com/paulchakravarti/pgwrap [2] https://news.ycombinator.com/item?id=11054944
* Simplified handling of connections/cursor
* Connection pool (provided by psycopg2.pool)
* Cursor context handler
* Python API to wrap basic SQL functionality
* Simple select,update,delete,join methods extending the cursor
context handler (also available as stand-alone methods which
create an implicit cursor for simple queries)
* Query results as dict (using psycopg2.extras.DictCursor or any other PG Cursor factory)
* Callable prepared statements
* Logging support
Essentially you can do stuff like: >>> import pgwrap
>>> db = pgwrap.connection(url='postgres://localhost')
>>> with db.cursor() as c:
... c.query('select version()')
[['PostgreSQL...']]
>>> v = db.query_one('select version()')
>>> v
['PostgreSQL...']
>>> v.items()
[('version', 'PostgreSQL...')]
>>> v['version']
'PostgreSQL...'
>>> db.create_table('t1','id serial,name text,count int')
>>> db.create_table('t2','id serial,t1_id int,value text')
>>> db.log = sys.stdout
>>> db.insert('t1',{'name':'abc','count':0},returning='id,name')
INSERT INTO t1 (name) VALUES ('abc') RETURNING id,name
[1, 'abc']
>>> db.insert('t2',{'t1_id':1,'value':'t2'})
INSERT INTO t2 (t1_id,value) VALUES (1,'t2')
1
>>> db.select('t1')
SELECT * FROM t1
[[1, 'abc', 0]]
>>> db.select_one('t1',where={'name':'abc'},columns=('name','count'))
SELECT name, count FROM t1 WHERE name = 'abc'
['abc', 0]
>>> db.join(('t1','t2'),columns=('t1.id','t2.value'))
SELECT t1.id, t2.value FROM t1 JOIN t2 ON t1.id = t2.t1_id
[[1, 't2']]
>>> db.insert('t1',{'name':'abc'},returning='id')
INSERT INTO t1 (name) VALUES ('abc') RETURNING id
[2]
>>> db.update('t1',{'name':'xyz'},where={'name':'abc'})
UPDATE t1 SET name = 'xyz' WHERE name = 'abc'
2
>>> db.update('t1',{'count__func':'count + 1'},where= {'count__lt':10},returning="id,count")
UPDATE t1 SET count = count + 1 WHERE count < 10 RETURNING id,count
[[1, 1]]
Also it allows you to create callable prepared statements (which I find really useful in structuring apps): >>> update_t1_name = db.prepare('UPDATE t1 SET name = $2 WHERE id = $1')
PREPARE stmt_001 AS UPDATE t1 SET name = $2 WHERE id = $1
>>> update_t1_name(1,'xxx')
EXECUTE _pstmt_001 (1,'xxx')
[1] https://github.com/paulchakravarti/pgwrap
[2] https://pypi.python.org/pypi/pgwrapI ended up writing my own very simple jail wrapper [1] (~200 lines of shell) which does most of this in a very simple way - I wouldn't advise this for general use but the code is simple enough to understand what is going on behind the scenes. I chose not to use jail.conf for my use case as I wanted to dynamically create/destroy lots of jails programatically and it was easier to just call jail(8) directly in the case.
[1] https://gist.github.com/paulchakravarti/9afea9e889bc992dbdd2...
m = 'most likely' time
o = 'optimistic' time
p = 'pessimistic' time
You can then estimate the expected time 'e' by modelling a triangular distribution based on these and sum the estimates on the critical path. e = ∑(oi + 4mi + pi)/6
This is actually a very useful technique but sadly is done very infrequently (probably because it usually comes up with an number that people don't want to hear - but is usually much more realistic).[1] https://en.wikipedia.org/wiki/Program_evaluation_and_review_...
The program (or project) evaluation and review technique, commonly abbreviated PERT, is a statistical tool, used in project management, which was designed to analyze and represent the tasks involved in completing a given project. First developed by the United States Navy in the 1950s, it is commonly used in conjunction with the critical path method (CPM).
Except of course - bash. It would be nice if people remembered that this isn't installed by default on lots of systems.
open -a SafariDoes anyone know if there is anything similar to afl-fuzz/go-fuzz for python?
[1] https://bitbucket.org/paulc/dnslib/ [2] https://bitbucket.org/paulc/dnslib/src/22cff0cd3e13098c00107...
There has been added in FreeBSD 11 but I am not sure how many of the commands have been converted.
python3.4 -m dnslib.client --server <ns1> --diff <ns2> <domain> <type> The libxo library allows an application to generate text,
XML, JSON, and HTML output using a common set of function
calls. The application decides at run time which output
style should be produced.
There is some work ongoing to convert FreeBSD utilities to support libxo [2] and a long thread on freebsd-arch [3][1] https://juniper.github.io/libxo/libxo-manual.html
[2] https://wiki.freebsd.org/LibXo
[3] https://lists.freebsd.org/pipermail/freebsd-arch/2014-July/0...
[1] http://en.wikipedia.org/wiki/Fourier_optics#Fourier_transfor...
There are still a lot of problems in the Perl 4 space and to be honest I wish that distributions shipped with a supported version of 4.036.
python -c 'import random;w=open("/usr/share/dict/words").readlines();print " ".join([random.choice(w).strip() for _ in range(5)])'Tweetnacl is 2 .c/.h files and c.1000 lines of code.