@ wrote... (5 years, 2 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... (5 years, 4 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... (5 years, 5 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, 7 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
@ wrote... (5 years, 7 months ago)

Don't check a pointer before deleting it, just delete it.

// don't do this
if ( p ) delete p;

// just do this
delete p;

// ie: this doesn't crash or do anything bad
int* p = NULL;
delete p;

// but you probably need something like this
#define NUL_DEL( p ) { delete p; p = NULL; }
NUL_DEL(p)

But seriously, this isn't the dark ages, you really want to be doing this.

std::shared_ptr<int> p;
...
p.reset(); // no need to set to NULL (or rather null_ptr)
Category: tech, Tags: cpp, programming, stl
Comments: 0
@ wrote... (5 years, 8 months ago)

I know next to nothing about Javascript so I'll need somebody who knows about this stuff to weigh in, but this is how I got jquery to load asynchronously and then fire callbacks.

more…

Category: tech, Tags: html, javascript
Comments: 0
@ wrote... (5 years, 8 months ago)

Depending on the hardware involved, you can dramatically speed up an ssh pipe by changing the encryption type, or turning off compression.

more…

Category: tech, Tags: linux, ssh
Comments: 0
@ wrote... (5 years, 8 months ago)

From what I can tell everybody uses net-snmp, and from what I've seen the documentation is atrocious.

more…

Category: tech, Tags: snmp
Comments: 0
@ wrote... (5 years, 9 months ago)

I'm not sure how else to name this entry, it's rather complicated. So what I was finally able to achieve is to pass a boost::bind to a boost::bind with placeholders, with templated callbacks. I'm not gonna lie, this took me awhile to figure out.

The rational for all of this was that I had a parent class called group, and this group had the list of boost::asio::deadline_timer's and the boost::asio::io_service running in a thread. I wanted the ability for child objects to put work in that thread.

more…

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

Django works much better if you do things the right way. Here are the steps for future me.

more…

Category: tech, Tags: django
Comments: 0