I gave a talk at PyGotham 2018 about how Python implements stack frames and how Dropbox leveraged that to improve crash reporting using Crashpad. I also contributed to the Dropbox Tech Blog post that goes into great detail on the crash reporting pipeline. The talk was less about Crashpad and more about Python internals. There is a video and slides. As part of preparing for the talk, I wrote the following post.
The inotify feature in the linux kernel allows you to receive events about changed files. Using pyinotify, here is a simple script to watch for changes to source code and run "make". Everything is hard coded right now, and since I was using CMake with out-of-source builds, the directory structure is that way. It also uses the command line notify-send tool to display notifications. Perhaps some day I will make it configurable and more useful.
The exams are over and I've been hacking a bit on the Arduino today. So I came up with a simple hack which blinks an LED on the Arduino if you've got unread mails in your Gmail inbox. I assume that you're familiar with the basics of Arduino. Equipment A computer with an internet connection Python pySerial Arduino ( I'm using Duemilanove ) Red LED Pushbutton (optional) Wires On the computer
Aside from some code cleanup, testing, and writing architecture documentation, Graffiti is good to go. You can Download it
After quite a few weeks of work, Graffiti has (again) reached the stage where it can render it's first words. It's now at 488 lines of code, of which the CSS related stuff itself comes in at 288 lines! There is no word wrapping yet, or any layout logic. I've been busy fixing quite a few bugs in the CSS overlays and so on. This is how you would use it.
It's quite common to use strings, integers and other 'native' Python data types as hash keys. But sometimes it is much easier to be able to use your own class instances as keys. Python's magic methods allow you to do this. Note: This is not a tip on implementing hash functions, this is how you can remove a certain layer of peeking around into objects __hash and __cmp__ Consider a useless HTML parser with a simple node design where you want to associate the node name with its attributes.
The Sierpinski triangle in Python, inspired by HTDP, and using Pygame import sys import pygame from pygame.locals import * class Point(object): def __init__(self, x, y): self.x, self.y = x, y def distance_sq(self, other): return (self.x-other.x)**2 + (self.y-other.y)**2 def distance(self, other): return sqrt(self.distance_sq(other)) def tupl(self): return (self.x, self.y) def midpt(p1, p2): return Point( (p1.x+p2.x)/2, (p1.y+p2.y)/2 ) def too_small(p1, p2, p3): return max([ p1.distance_sq(p2), p2.distance_sq(p3), p3.distance_sq(p1) ]) < 5 def draw_line(p1, p2, surf, col):
A new project of mine is Graffiti, a library over Pygame which allows application developers to write HTML and some CSS-like styling information and let Graffiti manage styling and rendering. It's no Gecko. Just something to solve an itch of handling word wrapping and styling in raw Pygame/SDL. The distinction between CSS and CSS-like is important and will be explained later. Write now I'm just on basic API design with no CSS parser, and all styles currently encoded in source.
Glowpad is a small Python/Pygame program to read in a file and generate a word/pattern with randomly coloured squares which morph to white. I basically wrote it after seeing the cool effect that appears at the end of one of the Sony ads(the robot one) where the same effect happens with the word feel. So I hacked this program in just half an hour. To run the program, extract it to any place on your computer.
Lasermania finally has something to see moving. Its this game where you have to arrange specific mirrors in proper places to guide a photon from emitter to reciever. Its written in pygame/python. In the screenshot you can see the photon(red dot) to the right. The emitter now fires a photon, drag and drop works(almost), only the mirror logic is left.