HNHacker News
TopNewBestAskShowJobs

_paulc

209 karma · joined November 10, 2013

submissionscomments
_paulc··on Show HN: Dply – Free temporary Linux servers
Was just about to ask for this - thanks for supporting. Very cool service btw.
_paulc··on Iocage – A FreeBSD jail manager
There are lots of jail wrappers but in most cases it is just as easily to just take the time to understand how jail.conf works and use this (see FreeBSD jails the hard way [1]). It's fairly easy to just use zfs clones to create jails and customise the exec.prestart/exec.start functions to do automatic provisioning and configuration (eg. I store the port forwards in a variable for each jail and process this and automatically setup pf rules when the jail starts).

[1] https://clinta.github.io/freebsd-jails-the-hard-way/

_paulc··on Show HN: sdees – serverless decentralized editing of encrypted stuff
(In .vimrc) set cryptmethod=blowfish2

vim -x scp://.../...

_paulc··on Show HN: Chext – a shell utility to change file extensions
In zsh:

  autoload zmv
  zmv '(*).baz' '$1.bar'
_paulc··on Records: Python library for making raw SQL queries to Postgres databases
Wow - this looks really really similar to my wrapper library (pgwrap [1]). See comment below [2]

[1] https://github.com/paulchakravarti/pgwrap [2] https://news.ycombinator.com/item?id=11054944

_paulc··on Records: Python library for making raw SQL queries to Postgres databases
It looks like a number of people have done something similar so though I would mention my attempt - pgwrap [1][2]. This is also a thin wrapper over psycopg2. This provides the following -

    * 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/pgwrap
_paulc··on Hacking the Zsun WiFi SD Card Reader
Unavailable...
_paulc··on FreeBSD Jails the hard way
Interestingly I just went through the same process as I wanted to understand how jails worked without the tools (my preference is iocage if you want something full featured - ez-jail doesn't properly handle the new jail.conf approach) - to be honest this is pretty simple and in some cases the tools just add complexity.

I 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...

_paulc··on Why Are Projects Always Behind Schedule?
Probably not, but I would guess that the difference is well within the error margin of the original estimates.
_paulc··on Why Are Projects Always Behind Schedule?
I think that the real value is in forcing people to think about optimistic vs worst case estimates - in my experience the initial estimate is almost always actually the optimistic number and when they start to think about risks people tend to become much more conservative.
_paulc··on Why Are Projects Always Behind Schedule?
The fact that planning estimates represent a probability distribution is well known and there is an established process (PERT)[1] for estimating the expected time of a set of estimates - essentially instead of asking for a single 'most likely' estimate you should as well explicitly walk through some of the risks around this and the ask for an 'optimistic' estimate (which is frequently very similar to the initial estimate) and a 'pessimistic' estimate (which is frequently much larger) - given:

  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).

_paulc··on Z – quickly cd to 'frecent' directories
just a bash script with no dependencies

Except of course - bash. It would be nice if people remembered that this isn't installed by default on lots of systems.

_paulc··on NASA official warns private sector: We’re moving on from low-Earth orbit
A better analogy would be if the Jamestown settlers had spent 10 years floating in the English Channel being resupplied by rowing boat rather than actually getting on with the business of crossing the ocean and settling somewhere. The whole programme is frankly a total waste of time and money which is a huge distraction to actually making any progress in manned space exploration.
_paulc··on OS X Command Line Utilities
The first of these is easier as:

  open -a Safari
_paulc··on Why telephone keypads are arranged the way they are
Isn't there a simpler reason - a square design is easier to implement with a 3x3 matrix switch and the number layout ensures that the letters associated with the digits are in alphabetic order.
_paulc··on Fuzzing a DNS parser written in Go
For dnslib [1] I use a much simpler fuzzer as part of the test suite [2] - this is nothing like as sophisticated as afl-fuzz or go-fuzz in terms of understanding and exercising code paths (just takes a DNS record and randomly mutates it - though still found a number of bugs).

Does 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...

_paulc··on Starfighter, Summer 2015
PIC32 is a MIPS core
_paulc··on Unix is not an acceptable Unix
See libxo[1]

There has been added in FreeBSD 11 but I am not sure how many of the commands have been converted.

[1] https://juniper.github.io/libxo/libxo-manual.html

_paulc··on Dnsdiff
If you have dnslib installed (https://pypi.python.org/pypi/dnslib) you can also do something like:

  python3.4 -m dnslib.client --server <ns1> --diff <ns2> <domain> <type>
_paulc··on Is the Unix shell ready for XML? (2006)
The Juniper libxo [1] library is an interesting approach which preserves the traditional text output but also gives an option to output structured data:

  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...

_paulc··on Arduino TRE
The AM355x already has 2 x 32bit Programmable Realtime Units (PRU) [1] so the AVR seems a bit redundant (other than compatibility with existing shields and ease of programming)

[1] http://elinux.org/BeagleBone_PRU_Notes

_paulc··on Perfect colors, captured with one ultra-thin lens
This looks somewhat like the concept behind a fresnel zone plate [1] - in general these are highly dispersive (only work at one frequency) so it looks like they have done something to address this. Many (30+) years ago my final year project at university was trying to dynamically synthesise lenses using by electronically manipulating the phase response across a liquid crystal substrate - technology wasn't really there at the time but always thought that it would have been an interesting avenue to follow up on.

[1] http://en.wikipedia.org/wiki/Zone_plate

_paulc··on Debian developer prompted to revisit FreeBSD after 20 years
I think that a lot of this depends on whether you want to run a desktop or server - a lot of comparisons focus on how Linux/FreeBSD compare as a user workstation. To be honest I wouldn't recommend anyone use FreeBSD as a desktop/laptop OS but if you want a 'production' server there is a lot to be said for simplicity and avoiding too many 'clever' features.
_paulc··on Let's review Docker
There are also some very old alternatives:

https://www.freebsd.org/doc/handbook/jails.html

_paulc··on 42 as a Service
Ironically there were 42 comments when I opened this.
_paulc··on Dirty lens article
Long time since I did any optics but this basically just convolution. The impact at the output plane of dust/imperfections on the lens is (approximately) a 2D fourier transform of the dust/imperfections. If you have a single dust particle (essentially an impulse) on the lens this will be convolved into a dc response at the focal plane.

[1] http://en.wikipedia.org/wiki/Fourier_optics#Fourier_transfor...

_paulc··on Shellfire – A repository of namespaced, composable shell function libraries
I'm a big fan of removing dependencies and very partial to distributing single dependency free executables, but don't you just need to install all the shellfire dependencies instead of Python/Ruby etc. Appreciate that you can 'fatten' apps but this is true for the other languages too (pyinstaller etc.).
_paulc··on Why Perl Didn't Win
Absolutely right - Perl 4 had a clear niche (text processing, UNIX system scripting etc) and did this very well. Perl 5 added so much cruft and ugly syntax on top of this in an attempt to try to become more 'general purpose' that it lost its focus. At this point it became easier to switch to Python for 'real' programming.

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.

_paulc··on A plastic card for easy to remember strong passwords
Or:

  python -c 'import random;w=open("/usr/share/dict/words").readlines();print " ".join([random.choice(w).strip() for _ in range(5)])'
_paulc··on Some gripes about nacl
Except that this is the opposite of my point - the libsodium repository is 9MB with 326 .c/.h files and c.25000 lines of code.

Tweetnacl is 2 .c/.h files and c.1000 lines of code.

← PreviousPage 2 of 3Next →