Selecting row number in MySQL

Michael Yakobi sent us this clever use of MySQL’s user defined variable syntax to return row numbers in a result set:

Occasionally, one wants to execute a query and have the rows in the results set numbered. This could be done using a variable. For example:

SELECT @row := @row + 1 as row, t.*
FROM some_table t, (SELECT @row := 0) r

I haven’t used this feature of MySQL before, but it looks like it could be pretty useful. The user defined variables are scoped to a connection but persist between statements, so you can use them to store intermediate state information between queries or even perform iterative calculation within a single query, as was done in the example above.

MySQL User-Defined Variables

Cause of ZUNE leapyear problem – Freescale date routine

itsnotabigtruck writes

After doing some poking around in the source code for the Zune’s clock driver (available free from the Freescale website), I found the root cause of the now-infamous Zune 30 leapyear issue that struck everyone on New Year’s Eve.

The Zune’s real-time clock stores the time in terms of days and seconds since January 1st, 1980. When the Zune’s clock is accessed, the driver turns the number of days into years/months/days and the number of seconds into hours/minutes/seconds. Likewise, when the clock is set, the driver does the opposite.

The Zune frontend first accesses the clock toward the end of the boot sequence. Doing this triggers the code that reads the clock and converts it to a date and time. Below is the part of this code that determines the year component of the date:


year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}

Looks like it’s a leap year thing and it might happen again in 4 years… For now those with ZUNEs can just wait a day. This bug and the android “run every word you type” bug – typing “reboot” would reboot the phone are 2008′s weirdest mobile device bugs.

Fuzzlab uber effects box

Fuzzlab
200812311929

Beavis Audio Research brings us the Fuzzlab, an fusion of 4 classic DIY guitar distortion circuits into one hefty tweakable unit. The construction was a very long and educational process -

Now that all is said and done, I learned a great many things from this project. I made a large number of mistakes and came up with a few mildly innovative ideas along the way. I also ended up with a huge pedal that looks cool :) Some Key Points:
  • Four fuzz circuits in one box adds some practicality to my rig, but not any hugely new tones. A fuzz into a fuzz sounds interesting, but not necessarily great.

  • My favorite of all the fuzzes is the Big Muff Pi clone. The Fuzz Face can sound good, but it can just be too much work to dial in *that* sound especially when the Fuzz Face isn’t first in the line of pedals.
  • Adding a voltage sag circuit to fuzz circuits adds a great degree of control you just can’t get otherwise.
  • A slight ring mod/circuit adds incredible nuances to your tone, with or without fuzz.
  • Never underestimate the amount of time it takes to do the integration work. I spent a total of about 20 hours populating, soldering and debugging the individual PCBs. It took over 150 hours to do the actual integration, wiring, drilling, etc. Now I understand why traditional pedal makers don’t take on something of this size.
  • I’ve learned enough in this project to build just about any pedal design out there–in other words, there are *some* good reasons for making your first DIY project overly ambitious!

Check out the project’s page for a bunch of really helpful tips and ideas – The Beavis FuzzLab

CNC tree

cncTree.jpg

My internet friend, David Erwin, had a crisis on his hands; the Christmas tree was a “brown, shedding, fire hazard and it ended up in the front yard on the 23rd.” Well, being a ShopBot owner (as well as the owner of the best darned mid-century modern door company out there, Crestview Doors) he did what any good maker would — he CNC’d a tree out of styrofoam! Go David!!

DIYBio for biohackers

crosswalk.jpg

Mac Cowell recently started the site DIYBio as a resource for biohackers working outside academic and industrial labs.

DIYbio is an organization that aims to help make biology a worthwhile pursuit for citizen scientists, amateur biologists, and DIY biological engineers who value openness and safety. This will require mechanisms for amateurs to increase their knowledge and skills, access to a community of experts, the development of a code of ethics, responsible oversight, and leadership on issues that are unique to doing biology outside of traditional professional settings.

One of their current projects is the BioWeatherMap, where you can help compare microbes on crosswalk buttons worldwide. Check out the Instructable about the process!

Not New Year’s resolutions – What are you going to MAKE? What we are making…

Every year there are lists and list of New Year’s resolutions, we’re not going to do that here at MAKE. This years it’s all about what you plan to make! I asked our team and advisory board to send me what they plan to MAKE in 2009 and here is what some of them are going to make!

Since I made everyone answer my email over the holiday break, I’ll start with mine :) Click “read more” to see over a dozen others from the MAKE team and our advisory board! Lastly, post what YOU plan to make in 2009 – I’ll check the comments at the end of the day and pick a winner (We’ll send you out the very popular Maker’s notebook).

Sany1340
Twittering power usage device

Limor Fried and I are working on a cool project that should be done in early 2009, you take an off the shelf power usage device like the Kill-a-Watt and add an Xbee wireless module – once tapped in to the Kill-a-Watt you transmit the power usage to a local computer and that computer publishes how many watts per day you’re using to your twitter account and will also add something like #mywatts so everyone can compare what they use. You could also use an Arduino with ethernet or wireless and eliminate the computer completely. The project will be open source of course and we expect someone will see it and do a commercial product.

Phillip Torrone, Senior Editor, MAKE Magazine

2964708347 022Cfe8B02 B
MRI art

I’m going to embroider the MRI slices of my knee into colorful little biscuits and arrange them suspended vertically to create a segmented 3D form. It should look half like an anatomical reference model, half like olive loaf.

Becky Stern, online author, CRAFT/MAKE



Arduino-powered Christmas Tree Mark II

One year ago, I built my first Arduino-powered Christmas tree. It’s a simple 8×8 LED matrix that I wove together myself, and drove with a MAX7219. The original was powered by a Bare Bones Board (Arduino clone), but when I broke it out this year, I used a Boarduino (left my BBB elsewhere). Not only will I make a better version, but I resolve to document it this time! I also resolve to use the Matrix.h library for Arduino instead of not RTFMing and doing the code the hard way. Video of me weaving the LED matrix & more build details.

Brian Jepson, Executive Editor for Make: Books


Pi Detector
Pulsed Induction Metal Detector “on the cheap”

My girlfriend wanted a the ultimate recession birthday gift — ideally one that was zero-cost (or could make money) — so I decided to make her a pulsed induction metal detector. Pictured is the analog front end for the detector, on top of the sense coil. The challenge is to make this with little more than the spare parts laying around my office, yet make it effective enough to operate on the salty San Diego beaches to try and find coins. I’m trying to be a little novel by designing a hybrid digital back-end for the detector, although as I learn more about the circuit’s properties and human psycho-perceptual factors, I am starting to see more wisdom in an all-analog approach.

bunnie — MAKE Magazine Technical Advisory Board


micro-tool.jpg

CNC XYZ gantry robot

This year I plan to make a Making Station. I am going to build a CNC XYZ gantry robot, to which I can attach various cutting tools etc. This will be my personal manufacturing workstation, and I can see it playing a part in many projects over the coming years. I hope to build a Lumenlab Micro, but I make take an even more homebrew approach.

Steve Lodefink, MAKE Magazine Technical Advisory Board


Azworkshop
New workshop

After other people who have the necessary equipment finish building the exterior of my new workshop, my big construction project in 2009 will be finishing the interior. I decided to make it big–slightly larger than my little house adjacent to it, on two acres in Northern Arizona. I will use it for fabricating prototypes of medical equipment, and for proof-of-concept electronics devices for a book that I am writing for Make Books.

Charles Platt, Section Editor, Upload, MAKE magazine


Arduino Midi Shield Proto
Arduino MIDI Shield

I plan to produce a finished Arduino MIDI shield in ’09 – capable of acting as a standalone synthesizer and MIDI to control voltage converter.  The early prototype is pictured here, still has a few kinks to work out in software/hardware.  I’ll keep y’all posted on progress.

Collin Cunningham, online author, MAKE


Fauxdue
Fake-fondue system

I’ve been working on a better fake-fondue system. Right now, I’ve put together a base prototype where we’ve got excellent heat transfer from the tea candles but the colander is not providing sufficient airflow. So Physicist Husband is helping to work out the airflow issues, perhaps by installing a small fan or upgrading to a better colander, which would kind of invalidate the point of using stuff we already had around the house.

Yes, I know, we could just go out and buy a fondue pot, but (a) where’s the fun in that; and (b) buying a special purpose device rather than working from first principals would be *wrong*.

The metal tray to the right in the picture sits on top of the colander and the saucepan with the fondue cheese goes onto the tray. In the past, we had used wooden building blocks in place of the colander and learned that, surprise!, wood burns. So we’ve moved on
from there.

That’s a small ceramic tile (from Home Depot’s bathroom department, handpainted as a rainy day project and modgepodged) under the tea candles. In the future, it will be wrapped in aluminum foil because blowing out the candles splashed wax all over the tile. Wax easily removed with hot water but also with son’s tears. Lesson: don’t use beloved tile projects for home improv.

The colander was picked for sturdiness, which it has in spades, but didn’t deliver on the airflow we hoped. The six tea candles provided enough steady heat transfer to keep the tray quite warm but the oxygen issue meant they kept going out.

Erica Sadun, MAKE Magazine Technical Advisory Board


Twomotorwalker123008
BEAM Two-Motor Walker

For all of my cheerleading of BEAM robotics, and all the articles I’ve written about this approach to robotics, I haven’t actually made that many different types of BEAMbots (e.g. never made a swimmer, a mini-ball, a headbot, a climber). I’ve never even made a walker from scratch, beyond the one-motor walker featured in my robot book (which is really a walking machine, not a proper robot). I’ve also never made a BEAM Bicore circuit that uses a master-slave Bicore arrangement for its control circuit. So this year, I hope to finally build the two-motor walker found in Dave Hrynkiw’s Junkbots, Bugbots & Bots on Wheels.

Gareth Branwyn, Contributing Editor, Maker Media


Joegggg
A variety of low-cost laser range finders

Many laser range finders that exist for robotics applications are very expensive (hundreds to thousands of dollars). I’m working on a number of laser range finder designs based on various detection techniques and technologies. It’s a great learning experience for me, since I’ve never worked with optics before and analog design has never been my strong suit, and the end result should be a few low-cost units that hobbyists can integrate into their own products. I’ve made some good progress during 2008, but plan to make this my priority in 2009!

Joe Grand, MAKE Magazine Technical Advisory Board


Gitane02-002
Year-of-my-birth bike conversion

This year I want to convert this 1972 Gitane road bike into a single speed. I know I’m getting a bit old to be a “fixie hipster”, but I really like the idea of building/riding/maintaining a minimalist bike with fewer moving parts than my current commuter bike. I’ll use a freewheel hub in the back, and I’ll put some brakes on it for sure.

John Edgar Park, MAKE: author and Make: television host


Pastedgraphic
DIY Eco Surfboard

Surfboards are a classic DIY project but frankly a toxic mess. So the guys at Greenlight Surfboard Supply have updated the traditional polyurethane/polyester/fiberglass board (landfill) with recyclable polystyrene, low-VOC resins, and bamboo fiber and laminates. Their kits include all materials and tools for shaping the foam, glassing your board, even drawing snazzy pinlines.

Keith Hammond, Copy Chief, MAKE and CRAFT magazines


Secret

You can’t possibly expect us to let your readership in on our secret plans, can you?

Lenore Edman, Evil Mad Scientist Laboratories, MAKE Magazine Technical Advisory Board


Open source hardware

In 2009 I would really like to MAKE ‘something’ that could be Patented. Instead of going through the arduous Patent process, I would open-source the project and see what happens. I am really interested in this business philosophy and the way the community can help further develop a product. The best way to learn about open-source hardware is to actually make something and release it into the wild.

Marc de Vinck, online author, MAKE


Chuckkkkkkkeb
Chicken Tractor

I am going to make a chicken tractor, which is basically a box covered with wired mesh, to allow my chickens to graze and scratch in my yard, but to keep them from wandering off the property where they might get hit by a car or eaten by a dog.

Mark Frauenfelder, editor-in-chief of MAKE


Re-making the yard

I have a small urban yard with lots of shade (and slugs!). I’ve grown some vegetables in years past with varying degrees of success. This year I want to convert more of the yard to producing fruit and vegetables organically and sustainably, using found and local materials for the infrastructure.

Patti Schiendelman, online author CRAFT/MAKE, Make:Books indexer/editor


The ChugMast’R

A mug with a tilt sensor that lights up increasingly as you empty it and goes crazy once you’ve drained it completely.  Great way to get kids to drink their milk, and also of possible value to fraternities.

Paul Spinrad, Projects Editor, MAKE


Ssssssssmosaic
Mosaic Tabletop

I found a 3-foot-diameter metal table base at the free section of the dump. Bruce bought a piece of hardiboard (a waterproof and sturdy building material) and I’ve been smashing up a box of broken dishes and tiles and laying them out in circles on top of the board. A friend who runs an art studio is helping me adhere the china and tile pieces and then finally grout it. Of course I’m referring often to the article we ran in CRAFT, Volume 09!

Shawn Connally, Managing Editor, CRAFT


Post what YOU plan to make in 2009 – I’ll check the comments at the end of the day and pick a winner (We’ll send you out the very popular Maker’s notebook).