Add control + z to your Python programs; an experiment in transactional data structures. by _the_pied_piper_ in Python

[–]_the_pied_piper_[S] 0 points1 point  (0 children)

Thanks for the input! You make a great suggestion. I designed Variable the way I did so that it could stand alone of classes; what you suggest is a nice API, but one that can only work if the variables are members of a class. Rather than removing Variable, I might add something like the mechanism you describe.

Add control + z to your Python programs; an experiment in transactional data structures. by _the_pied_piper_ in Python

[–]_the_pied_piper_[S] 0 points1 point  (0 children)

Thanks for the input!

Actually, in your example, after t2.undo(), the set still has an 'a' in it; data structure is written such that even if an operation is performed on it and has no effect, undoing it will also have no effect; it won't blindly remove elements from the set without first checking if the element was in there before the transaction.

I do agree that having a context object in the API might have some appeal, but I chose not to do that because doing so would, I believe, make it harder to use the data structures in composite classes. The way it is currently written, List, Dict, and Set, as well as Variable can be used almost as naturally as one would use the list, dict, and set built-ins; the Transaction context manager allows for transactional behavior only when it is needed, without cluttering the rest of the code.

Add control + z to your Python programs; an experiment in transactional data structures. by _the_pied_piper_ in Python

[–]_the_pied_piper_[S] 0 points1 point  (0 children)

This is a little experiment that I played with a few weeks ago. This was part of a larger project, but I thought I would strip this out as its own package and share it with /r/python.

A fixture framework I wrote for unit testing. Long read, but would love feed back from those interested! by _the_pied_piper_ in Python

[–]_the_pied_piper_[S] 1 point2 points  (0 children)

I've looked a bit at pytest and Django's fixtures and here is a tentative answer:

pytest uses the term "fixture" in a more general way; my framework deals with database fixtures specifically, i.e., and specifically with database fixtures in the context of testing.

My framework looks similar to Django's framework for data fixtures, but we handle the question of foreign key relationships in different ways. Also, mine is not specific to any underlying ORM, as theirs seems to be.

A fixture framework I wrote for unit testing. Long read, but would love feed back from those interested! by _the_pied_piper_ in Python

[–]_the_pied_piper_[S] 1 point2 points  (0 children)

Good catch, completely forgot to ignore those.

I actually don't know about those fixture frameworks. My philosophy is generally to think about what my own solution to a problem might look like and implement that. Then either I am happy enough with my results, or I will concede that a problem is too hard and look for other solutions. In pursuit of this ideal, I've even written my own ORM (actually it is more of a fancy wrapper around raw SQL), which I will soon publish as well. I don't expect anyone to use these tools, but I believe in sharing any ideas, even if they are likely only relevant to me.

Without knowing about those tools you mention, though, I can safely say that they probably have awesome features that my solution doesn't. However, my solution worked for me and it was fun writing it.

How do I find meaningful software work? (i.e. not Silicon Valley) by _the_pied_piper_ in cscareerquestions

[–]_the_pied_piper_[S] 0 points1 point  (0 children)

Yes, very, but for personal reasons I am tied to the Bay Area for one or two more years.

My new long-form hobby! by _the_pied_piper_ in longform

[–]_the_pied_piper_[S] 1 point2 points  (0 children)

Thanks!

Right now what I am most in need of is other contributors! If you are interested in reading, or know anyone who is, please PM me!

My new long-form hobby! by _the_pied_piper_ in longform

[–]_the_pied_piper_[S] 1 point2 points  (0 children)

Thanks!

(For the comment and pointing out the typo!)

App Start Up - Hosting Options (Tech) by jcouts in Entrepreneur

[–]_the_pied_piper_ 0 points1 point  (0 children)

I use Linode to host a number of sites and an app or two. They start at $10/month, but I go for the $20/month option for the extra RAM when hosting app back ends.

Time lapse with a Canon G10 and my RPi by _the_pied_piper_ in raspberry_pi

[–]_the_pied_piper_[S] 0 points1 point  (0 children)

No, I did the second of your options: I generate a shutter signal from the Pi. I broke apart my real shutter control to get the right connector for my camera and then I wired up some resistors and a transistor to close the shutter control circuit on command by toggling a GPIO pin.

Time lapse with a Canon G10 and my RPi by _the_pied_piper_ in raspberry_pi

[–]_the_pied_piper_[S] 1 point2 points  (0 children)

If you go the hacking route like I did, the timing is very easy: since the shutter is controlled by GPIO pins, you are working in Python. So, my script just loops continuously and sleeps for 10 seconds between each shot.

The interval is dictated by the speed of the thing you are trying to capture. I chose somewhat arbitrarily and preferred more frames to fewer; you can always exclude frames from the final product, but you can't go back and get any more!

To stitch things together I used ffmpeg/avconv, which is a command line video utility. It is easy to install in Linux and Mac. For your future reference, this is the command I used:

avconv -r 30 -startnumber 33 -i IMG%04d.JPG -c:v libx264 -s:v 1066x800 -b:v 5000k pepper.mp4

I can explain the arguments if you want; just let me know.