Python With Braces

python

If there’s one thing about Python that’s slightly disconcerting, it’s the complete lack of braces, or as they’re called in American English, suspenders. A feature of every variety of C, Java, PHP, Perl, and a whole bunch of other very powerful languages, braces make things more legible and don’t rely on precise indentation. [Ruby] and [Eran] have come up with a way to use these punctuation marks with Python in a project they call Python with Braces.

As its name implies, Python with Braces doesn’t care about indentation: you’re free to make you code extremely ugly, or write your code properly in K&R style. Each line is terminated in a semicolon, and blocks of code with only one statement don’t require curly braces, just like C and Java.

Right now [Ruby] and [Eran] have a Windows installer with an OS X package on its way. Executing a Python with Braces script only requires executing it with a ‘pythonb’ executable instead of the normal ‘python’ executable.

Serializing Dickens to LEDs

ch00fmas12

[ch00f] managed to capture some holiday spirit this year by translating all of A Christmas Carol to scrolling text. Dickens’s work has long since entered public domain, which led [ch00f] to wire up a GeekCatch programmable display from Amazon. It has a low refresh rate, which means videos look a bit goofy, but it’s perfectly acceptable for text. [ch00f] ditched the remote control and instead used the display’s serial connection to program in the novella. Unfortunately, he could not find any documentation for the serial protocol, but he was able to reverse engineer it with some freeware applications found online.

It takes over six hours for the sign to spit out the entirety of A Christmas Carol, which easily surpassed the display’s limited text buffer. [ch00f] instead had to send text to the display one paragraph at a time via a custom Python script. This solution takes advantage of the sign’s fixed-width font to estimate the time it takes for each character to scroll by, then immediately feeds the sign a new line.

Check out the blog post for a quick teardown of the display itself and for a detailed description of the protocol in case you decide to use this display for a project. Stick around for a video below!

[Read more...]

Will Dance For Bitcoin

Bitcoin Bot

It seems that Bitcoin is all over the news nowadays, but the Bitcoin Bot is probably the first robot that will dance for Bitcoins.

[Ryan] at HeatSync Labs in Mesa, AZ, is a fan of the cryptocurrency, and decided to build something to accept it. He discovered that Coinbase, a popular hosted Bitcoin wallet service, has a callback API. This causes Coinbase to fetch a specified URL any time a wallet receives a transaction, and provides information on the transaction in the request. A Python script handles these requests and updates a running count of the BTC balance sent to the robot’s wallet.

On the hardware side, an Arduino with an Ethernet Shield checks the balance. If it has changed, it calls the dance function and the luau girl dances.

The robot sits in the window of the hackerspace, so anyone passing by can read about Bitcoin and make a donation. The source code is on Github, and a video follows after the break.

[Read more...]

Interview with [Damien George], Creator of the Micro Python project

upython

[Damien George] just created Micro Python (Kickstarter alert!), a lean and fast implementation of the Python scripting language that is optimized to run on a microcontroller. It includes a complete parser, compiler, virtual machine, runtime system, garbage collector and was written from scratch. Micro Python currently supports 32-bit ARM processors like the STM32F405 (168MHz Cortex-M4, 1MB flash, 192KB ram) shown in the picture above and will be open source once the already successful campaign finishes. Running your python program is as simple as copying your file to the platform (detected as a mass storage device) and rebooting it. The official micro python board includes a micro SD card slot, 4 LEDs, a switch, a real-time clock, an accelerometer and has plenty of I/O pins to interface many peripherals. A nice video can be found on the campaign page and an interview with the project creator is embedded after the break.

[Read more...]

How Hacker News Page Rankings Really Work

hacker-news-page-rankings

Page rankings are the secret sauce of websites that automatically aggregate user submissions. The basic formula used by Hacker News was published a few years back. But there are several pieces of the puzzle that are missing from that specification. [Ken Shirriff] recently published an analysis that digs deeper to expose the article penalization system used by Hacker News’ ranking engine.

One might assume that the user up and down votes are what determine a page’s lifespan on the front page. But it turns out that a complex penalization system makes a huge difference. It takes into account keywords, and domain names but also weighs controversy. It’s a bit amusing to note that this article on the topic was itself penalized, knocking it off of the front page.

You can get the full details of the system from his post, but we found his investigation methods to be equally interesting. He scraped two pages of the news feed every minute using Python and the Beautiful Soup package (a pretty common scraping practice). This data set allowed him to compare the known algorithm with actual results. What was left were a set of anomalies that contained enough sense for him to reverse engineer the unpublished formulas being used.

Raspi Mini Laser Engraver

raspiLaserEngraver

If you’ve got a lot of spare parts lying around, you may be able to cobble together your own laser engraver without too much trouble. We’ve already seen small engraver builds that use an Arduino, but [Jeremy] tipped us off to [Xiang Zhai's] version, which provides an in-depth guide to building one with a Raspberry Pi.

[Xiang] began by opening up two spare DVD writeable drives, salvaging not only their laser diodes but the stepper motors and their accompanying hardware, as well as a handful of small magnets near each diode. To assemble the laser, he sourced an inexpensive laser diode module from eBay and used a vise to push the diode into the head of the housing. With the laser snugly in place and the appropriate connecting wires soldered on, [Xiang] whipped up a laser driver circuit, which the Raspi will later control. [Xiang] worked out the stepper motors’ configuration by following [Groover's] engraver build-(we featured it a few years back)-attaching the plate that holds the material to be engraved onto one axis and the laser assembly to the other.

Check out [Xiang's] project blog for details explaining the h-bridge circuits as well as the Python code for the Raspi. As always, if you’re attempting any build involving a laser, please use all necessary precautions! And if you need more information on using DVD burners for their diodes, check out this hack from earlier in the summer

Wireless Encryption Between Galileo and a MSP430

[Mark] recently finished his latest project, where he encrypts wireless communications between the new Intel Galileo and a Texas Instruments MSP430. The wireless interfaces used are the very common nRF24L01+ 2.4GHz transceivers, that had a direct line of sight 15 feet range during [Mark]‘s tests. In his demonstration, the MSP430 sends an encrypted block of data representing the state of six of its pins configured as inputs. This message is then received by a sketch running on the Galileo and stored in shared memory. A python script then wakes up and is in charge of decrypting the message. The encryption is done using AES-128bits in Electronic Codebook mode (ECB) and semaphores are used to prevent simultaneous accesses to the received data. As it is the first project using an Intel Galileo we received, don’t hesitate to send us a tip if you found other ones.

Follow

Get every new post delivered to your Inbox.

Join 92,278 other followers