Cron jobs are your friend

Recently I had to deal with data loss from a postgresql database. So, after painfully recreating the data and schema it was time to setup a cron job to prevent this happening again. The following script should prevent that in the future (thanks to http://www.nzlinux.com/2010/06/daily-postgresql-backups-script/).

#!/bin/bash
DIR=/backup/pgsql

#Database backup
LIST=$(su - postgres -c "/usr/bin/psql -lt" |/usr/bin/awk '{ print $1}' |/bin/grep -vE '^-|:|^\||^List|^Name|template[0|1]')

#Set current date for backups
DATE=$(/bin/date '+%Y%m%d');

#Remove old backups
rm -rf $DIR/

#Create and own backup
/bin/mkdir -p $DIR/$DATE/
/bin/chown postgres:postgres $DIR/$DATE/

#Cycle databases, get backup, save
for d in $LIST
do
su - postgres -c "/usr/bin/pg_dump $d | gzip -c > $DIR/$DATE/$d.sql.gz"
done

Monday, March 5, 2012

Checkbook HD v1.0.7

Checkbook HD is now at v1.0.7. This is the first time I have felt comfortable enough with the app to give it the version of at least 1.

In version 1.0.7, there are three new systems: Budgeting, Searching, and Split Transactions. These systems are what they sound like. The budget system allows one to create and track spending based on categories. Searching allows one to search by text strings, date ranges, accounts, transaction status, etc. Split transactions allows one to assign multiple categories to a single transaction.

Also in v1.0.7 is a fix to a major issue that has been plaguing Checkbook since the webOS update to 3.0.5. The fix should take care of the majority of the long loading issues. I've also implemented a fix into the Import/Export systems that should take care of some issues they were having.

Sunday, February 19, 2012

MakerBot Replicator

Just bought a MakerbBot Replicator. I am very excited to say the least. Odds are I'm going to burn though the initially provided 2kg of abs plastic with a week or two of arrival. It'll be pretty fun (and frustrating I'm sure) to build new parts for my robotics work and costume bits. I know one of the first costume parts I'm building is going to be for Mass Effect 3 costumes, the M-5 Phalanx. More to come when the 3d printer arrives.

Wednesday, January 25, 2012

EnyoJS Released

Today HP released Enyo as open source. They also announced Enyo 2, which will increase its cross platform and browser compatibility (along with many more great changes). That makes today a great day. With this release, I can code once and deploy a web app to webOS, Android, iOS, and other WebKit enabled browsers with ease.

With Enyo 2, I'll be able to write it once and deploy it on all those systems and on any web browser with modern web runtime. Enyo 2 currently does not have UI elements built in but that is planned for a March 2012. With that release, it'll be fun to see what I can convert at work to use this new and awesome framework.

I'm not the best at reporting all that is going on, so I direct you to enyojs.com. That is where the framework now exists (and on github, that is linked from the enyojs homepage).

Friday, December 9, 2011

webOS - Open Source

So webOS, my favorite mobile os, is becoming open source. Good. I am eager (and slightly fearful) of what is to come now.

The bad is all the unknowns of a big company open sourcing a product they don't seem to care for at times. Will HP only opensource it and then forget it or will the entire ecosystem flourish under this license? Will the software die without a dedicated hardware platform?

The good news is it'll be easier for me to write my apps for multiple OSes and for the web in general. So eventually Checkbook (and whatever other apps I decide to build/open up) will be available in all sorts of places and on many operating systems. So Android people, when HP opens enyo up, prepare for a big change in your Checkbook app.

http://www.precentral.net/hp-open-source-webos-no-hardware-plans-or-partners-announced
http://www.precentral.net/open-source-plan

Thursday, June 9, 2011

Website Redesign

I recently redesigned the GlitchTech Science website. While I did not add much design related content, I did update several chunks of code that control it. The site now uses jQuery UI in several areas. The most visible items are the left side navigation (I still need to tweak it more) and The home page blog view.

I'm not fully happy with the navigation system on the site yet. It is functional and I do like it better than the previous system. For those who didn't see it, the previous system was a top bar with mouse-over drop downs. It was easy to move your mouse outside of the drop down element and loose the stack. Not the best way to do things. Now the sidebar relies on mouse clicks on the arrow buttons. Clicking one opens a section; clicking again closes it. Clicking the title of the section has inconsistent behavior. If it is a link, it will take you to that webpage. If it isn't, it doesn't do anything. For now, that is disabled as it really sucked to use. In a future revision I need to make it a more consistent interaction. I'd also like to make it so a section will open up automatically if it contains a link to the current page.

The blog view uses the RSS feed from my Blogger account to render the content. It uses MagpieRSS to parse the XML content. The content is then formatted and placed in a jQuery UI Accordion system. This allows me to have three of the most recent posts rendered with all the content present and then have a list of links to past posts in a fourth divider.

Besides those visible changes, I also changed a few areas of the PHP code running things. I'm most happy with my changes to the navigation code. Before it was a jumble of links manually typed out. Now it is a recursive list generator based on the array passed in. The array can be nested as deep as needed, too deep of a nesting makes for a horrible list to navigate. If you would like the code, it is available at http://glitchtechscience.com/code_samples/arrayToList.php.txt.

Thursday, June 2, 2011

GlitchTech Checkbook - Finance Management Application for Android Devices

GlitchTech Checkbook, a financial management application, allows you to efficiently track your finances on your Android-enabled device. Checkbook allows you to create many different accounts, and each account can hold thousands of transactions. Track incomes, expenses, and transfers between accounts with ease, and back up your data with Google Spreadsheets. Checkbook is currently in development, with new features added often.



To get GlitchTech Checkbook, choose a method below:
GlitchTech Checkbook
QR Code

    Friday, April 22, 2011

    Analog Line Follower + Custom PCB [Part 1]

    For the final project in my analog electronics course, the assignment was to make an analog circuit. This circuit had to have at least three transistors or op-amps and do something. Some groups are making amps for their guitar, others are build analog computers. I decided to rebuild one of my first robots in analog form.

    Originally this bot used an ATMega8 to follow a line on the ground. It used a couple photo-resistors and LEDs to determine if it was on the line. The Thing worked pretty well, but had some trouble on low contrast surfaces.

    In its analog rebirth, I am using only transistors to make the same logic decision as before. I'm also only using a single photo-transistor to follow the line instead of several photo-resistors. This version of The Thing will use a home made PCB instead of a tangle of wires soldered directly to the pins.

    I started off by using other analog robots as resources to figure out what sort of design I needed. After a lot of digging and some testing I eventually ended up with a schematic and parts list in Eagle CAD (awesome circuit design program). Using Eagle awesomeness, I turned it into a single layer PCB design.

    Board schematic [Eagle CAD]
    Board design [Eagle CAD]

    I decided to make my own PCB instead of using a breadboard. The process of actually making my own board would give me brownie points, if not actual points, on my final project.

    I thought about ordering a short run but the production and shipping times for sites like BatchPCB would put delivery after the project was due. The cost of doing a short run elsewhere was too high for me to consider as well. So I went with etching my own at home.

    My first search brought me to the Society of Robots website and a guide there on making a PCB. It listed all of the steps but was very vague on some of the materials or curing periods. I ended up following a guide posted by the Cal Poly Robotics Club. To my surprise, Radio Shack still carries etchant solution and copper clad boards. The etchant is actually a ferric chloride (MSDS). I picked up a bottle and a board and started to work that night.

    Using a laser printer available on campus, I printed out my design onto some glossy paper and ironed it onto the cleaned and scrubbed board. After a lot of soaking and scrubbing and more soaking, I got most of the paper off. Next time I need to use lower quality paper, it did not want to break down/dissolve/act wet even after an hour submerged and scrubbed. About 95% of the ink traces were intact. I fixed those that weren't with some permanent marker.

    Inked copper clad board
    The etching process went much quicker. I poured about 1/4 to 1/2 in of etchant into a plastic container and microwaved it for 30ish seconds (outside of course, I don't know what the heated chemical odors could do to me and I would rather not experience them first hand). I tossed in the board and kept the liquid moving the whole time. Every so often I would take the board out and gently wipe it off with a paper towel. This helped speed up the process greatly. After 20 to 25 minutes, the board was done. I washed it off with soapy water to make sure the etchant was gone. Then I washed the board with acetone to get rid of all the ink.

    Etched and cleaned board
    A few basic tests with a multimeter showed that all the traces were good. Nothing connected where it shouldn't have either. Not bad for my first try. The next step is to drill out the holes and solder in the components. Sadly, I forgot to purchase a bit small enough to work. The smallest I have is 1/16in and I need something closer to 1/32in bit for the through hole components.

    I'll be checking Ace for a tiny drill bit tomorrow. I'm bringing along a few components to make sure the sizing is correct.