@ wrote... (3 years, 8 months ago)

I recently needed to have a pool of objects and it would make everyones life a lot easier if those objects would automatically return themselves to the pool when they were done.

Here's my take on a shared pointer pool.

more…

Category: tech, Tags: boost, cpp
Comments: 0
@ wrote... (4 years, 3 months ago)

This is a quick and dirty config guide to setup git-http-backend with uwsgi from supervisord on nginx. I did this on Fedora 20 so on a different distro some paths will likely be different.

I've also ignored security in this post as I have ssl termination handled elsewhere. This will send your password in the clear if you don't have ssl setup correctly! Don't forget to setup git permissions as well. This config allows any authorized user (somebody who can login) to push.

more…

Category: tech, Tags: git, linux, nginx
Comments: 13
@ wrote... (4 years, 4 months ago)

OMG I HATE MY LIFE SOMETIMES

So… I'll hopefully write more about this later, but the TL;DR is do not use monitor.py and uwsgi.

So if you have something like this in your wsgi.py, comment it out with extreme prejudice.

import monitor
monitor.start(interval=60)

Symptoms include, but not limited to:

  • workers not shutting down
  • workers appear to hang and cause 50x errors
  • workers not restarting if you send appropriate signals
  • workers appear to work once or twice then hang
  • workers never work
  • randomness and non-determinism all over the f'in place
  • little to no helpful log output
  • propensity to start adding lots of config variables that you don't understand
  • propensity to start drinking
  • wondering htf everybody else seems to use this software without a problem
  • wondering if perhaps computers where a poor career choice after all

I haven't looked into too closely but I suspect the fact that the monitor opens up it's own thread and runs forever has something to do with it. Open files, open sockets, stuff like that.

Category: tech, Tags: django, linux, nginx
Comments: 0
@ wrote... (4 years, 4 months ago)

In your muttrc you should have something like the following:

set query_command = "goobook query '%s'"
bind editor <tab> complete
bind editor ^T    complete-query

and if auto-completion of aliases isn't working make sure you don't have:

bind editor <tab> complete-query
bind editor ^T    complete

Note that the complete-query vs complete. Ctrl-T runs your query_command whereas tab auto-completes as appropriate (likely from your alias list).

That took too long to figure out…

Category: tech, Tags: mutt
Comments: 0
@ wrote... (4 years, 7 months ago)

For funsies I ported my mazesolver to pypy.

See update 2 for reference.

more…

Category: tech, Tags: mazes, python
Comments: 0
@ wrote... (4 years, 8 months ago)

This pattern which I thought up (but is likely not unique) can very nicely manage your service configurations, automatically reload/restart your service, and even give non-root users (if desired) the ability to modify system config files.

All through the magic of git hooks. This example tracks config files for Apache (httpd).

more…

Category: tech, Tags: git
Comments: 0
@ wrote... (4 years, 8 months ago)

Python tempdir.mkdtemp() has an annoying feature, it doesn't clean up after itself.

This idea comes from my friend and colleague Mike.

more…

Category: tech, Tags: python
Comments: 0
@ wrote... (4 years, 10 months ago)

Do you have a function called Enable() and another called Disable(). Make those two private and make a third:

void Enable(bool enable) {
  if ( enable )
    Enable();
  else
    Disable();
}

// now change all your calling code from
if( x == y )
  Enable();
else
  Disable();

// to
Enable( x == y ); // 4 lines are now 1

As per my example above, four lines got compressed into one line but nothing actually changed. The algorithm is identical but you now have fewer lines to think about and worry about. And all of this multiplies. If you make that change 4 times you've removed 12 lines of potential bugs and oversights.

Category: tech, Tags: cpp, programming, simple
Comments: 0
@ wrote... (4 years, 11 months ago)

I've finally gotten around to uploading a little project I did years ago. any_config is a template class that implements a somewhat fancy prototype pattern.

Read about at github.com.

Category: tech, Tags: boost, cpp, programming
Comments: 0
@ wrote... (5 years, 2 months ago)

This was originally the majority of this post: Start a django project the right way but I've decided to put in it's own post instead.

I'm assuming you're on OSX. If you're on Linux most of these steps will be the same. If you're on Windows… Install VMWare and then install Linux.

I've added a tl;dr at the end.

Although I have tweaked this over the years, the original code came from (I think, I've long since lost the bookmark) klymyshyn.com

more…

Category: tech, Tags: python, shell
Comments: 10