Monday, August 15, 2011

Idea: Frensel Lens Foundry

While browsing around the interwebs, I came across the fact that Frensel lenses have a great ability to focus sunlight. Naturally, I was surprised to find that such a great invention is being so under-utilized. (kind of like deck prisms which have just been "discovered" recently)


Anyhow, it turns out that these powerful lenses can be found in projection televisions, and best of all, people give these things away on Craigslist, because the TVs are broken.

A rather devilish plan came to me: why not melt aluminum cans in to small ingots? Sure, the use of these ingots would be rather limited, but you never know!

A quick trip to YouTube confirmed that things like steel could be melted with a lens about the size of a television, it has a melting point about twice that of Aluminum.

And now comes the really cool part: maybe it could be automated, an Arduino to track the sun and move the lens, a chute to feed aluminum cans, and some kind of a pot to catch the molten metal.

I like the idea of dumping the liquid in to a muffin tin, ensuring the metal comes out properly, although it could simply be poured back in to another soda can with the lid removed.

If for nothing else, the ingots could be used to save space while you gathered enough cans to take them to the recycling center.

Tuesday, August 2, 2011

Liberate Your Data!

Google has announced a new project from the Data Liberation Front team that will eventually help you download all of your data from Google, making their job that much harder to keep you as a customer. That is fine and dandy, and will be lovely once completed, but what do we do in the mean time? I know that you keep weekly backups of your computer, and probably monthly backups of your on-line presence in at least one location away from your computer that is, at minimum secured from fire and water, right?

If you do; this article probably isn't for you. Being an avid user of Google, I'll show that, along with Facebook, and Firefox Bookmarks and Software Keys hiding on your machine.

 Gmail:
Sorry, the options are limited here, either you set up a sync with a desktop client and copy the messages you get there, or you print all of your archived messages to PDF. Please don't print them to paper, that defeats the whole purpose of email.

Google Contacts:
This one isn't too bad, in the main Gmail window open your contacts.
Then choose More Actions > Export:
From there you will get many options for export, I choose to export all of my contacts in the Google format:




Once downloaded please rename the file from google.csv to something useful, like "contacts-export-2055-02-31.csv".




Google Docs
Open up Google Docs 


Select some documents, then from the "Actions" menu, choose download.


A dialog will pop up asking you how you want to download the documents, at the top, choose the tab for All Documents, then download in any format that works for you (I choose ODT because it is an open standard that is going to be around far in to the future).


This time your export is named something appropriate, like "documents-export-2011-08-02.zip".


Facebook
Facebook isn't as nice as Google and only sometimes works, when it does, your download may take days to process; get out while you still can!

First, open your account settings:

Then select, "Download a copy" of your Facebook data.



Then, press Download twice:


Within a few days (this only works about half of the time) you will get an email telling you that your download is ready, you can then click it, login to Facebook again, and download a zip file with all of your stuff. Note that my whole Facebook probably has ten Mb of data, it isn't big by any standards, yet it still takes a long time; probably because Facebook is stuck using MySQL and PHP for half a billion users. Those MySQL databases can't handle it, so they have to have lots of redundant servers and things have started going funky recently with keeping the information in each concurrent (I've started getting notifications about the exact same message hourly recently). Get your information out before Facebook begins to have seizures and starts dumping your stuff.

Firefox Bookmarks
This isn't that big of a deal: Open your bookmarks manager, Firefox > Bookmarks > Show All Bookmarks (Ctrl + Shift + O) then from the Import and Backup dropdown choose Backup. You will get a JSON file filled with your bookmarks.

Note that recent versions of Firefox also backup locally every few weeks.

Software Keys
Use the Magical Jellybean Keyfinder free version to view the software keys on your system and save them to a text or csv file.

New: Google Takeout

This is the new technology discussed at the intro to this post, head over to google.com/takeout and choose what you want to download, eventually all Google services should appear here, but for now you get Picassa, Google Contacts, Buzz, and Google+.

Tuesday, July 5, 2011

Almost a month.

It has been quite a while since I've published something; GSoC has kept me pretty busy these past few months, and I find myself despising the idea of looking at a computer after I'm done with it so I haven't done much computing recently, save for a little work with the Arduino which I'll probably post about a little later on today or this week.

Friday, June 10, 2011

Book Safe

It has been a while since I've posted something not computer related: well, here you go! Have you ever wanted a book with a hollow middle you can hide things in? Well, I did. Anyhow, the computer science department at the university I attend gets rid of old books by laying them on a table outside the office; most are hard-covers from earlier days. I picked up one on electrical and electronic engineering, to my dismay when I got home I found it to be filled to the brim with calculus. For that reason, I didn't feel bad at all cutting it up.


Time for the recipe:

Materials:
  • Hard cover book.
  • Craft Knife
  • Saw
  • Glue
  • Tape
  • Clamp (optional)
  • Felt (optional)
Methods:
  1. Slice out the inside of the book by running a craft knife along the page that connects the inside to the spine on both the front and back covers, this will leave both the spine and inside pages intact.
  2. Starting from the binding use the saw to slice down the sides of the internal pages of the book about an inch from the edges, until you are about an inch away from the side opposite the binding. I found a clamp helpful in keeping the book still.
    Finished Sawing, Use the craft knife to cut the rest.

    Clamping The Book For Sawing

  3. Using the craft knife, cut through the remaining pages along the outside of the book a few at a time, discarding them as you go to make a U shaped piece of paper.
  4. Finally, glue the spine back in to the cover of the book, and one side of the insert to the cover; spread glue over the inside of the pages to keep them joined, or use tape. If you really want, once the glue has been spread use felt to line it.
    Nearly Done!

I won't show you the cover, because then you would know which book it is!

You could potentially put a fake cover on this, something insane and boring, like "Multi-variable Calculus Pertaining to Optimal Cement Mixing" then stick it in the proper place in your library; a kind of cache for you. Anybody really interested in cement mixing will pass right over it knowing it is rubbish, while anybody new to the subject will go pale at the thought of doing calculus for such a seemingly simple problem.

    Wednesday, May 25, 2011

    Email Me At...

    I have long looked for a feature for Gmail that will delay sending a message until a certain time. Recently I wanted to send a good friend a Happy Birthday message, right when it was her birthday (one second after midnight). If only there was some way to do that...

    Luckily, I didn't have to stay up until midnight to do it, but rather cobbled together a nifty Python script that will wait until a given time, then send a message (including HTML if you have it).

    #!/usr/bin/env python

    import datetime
    import re
    import smtplib
    import time

    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText

    gmail_user = "yourname@gmail.com"
    gmail_pwd = "MyP@$$W0Rd"

    def mail(to, subject, body):
    msg = MIMEMultipart('alternative')

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    if '<html>' in body:
    msg.attach(MIMEText(re.sub(r'<.*?>', '', body), 'plain'))
    msg.attach(MIMEText(body, 'html'))
    else:
    msg.attach(MIMEText(body, 'plain'))

    m = smtplib.SMTP("smtp.gmail.com", 587)
    m.ehlo()
    m.starttls()
    m.ehlo()
    m.login(gmail_user, gmail_pwd)
    m.sendmail(gmail_user, to, msg.as_string())
    m.quit()

    if __name__ == "__main__":
    while datetime.datetime.today() < datetime.datetime(2011, 5, 24):
    time.sleep(1)

    mail("someone_else@gmail.com", "subject",
    "<html><b>bold body</b> non-bold body</html>")

    Things to Note:
    • Line 11-12, you will need to enter your Gmail address, along with your password in plaintext, so be careful.
    • Line 21, If the body of the message you want to send has the tag <html> it will be sent as an HTML message, all tags will also be stripped and a plaintext version will be put in the document as well.
    • Line 36, The date you use needs to be in ISO format, YYYY-MM-DD, if you want you can even add HH, MM, and SS like this:
      datetime.datetime(2011, 5, 24, 13, 5, 19)
    • Line 39: The first param is the address you are sending to, the second is the subject, and the third is the body (with or without html).
    Making one of these read from a .csv file could be insanely useful.

      Wednesday, May 18, 2011

      Three Comics

      It is unlikely that I'll become Randall Munroe any time soon, but hey, I figure I'll just share these while my code is compiling for the "One Hour Linux Distribution With an X-Server" (if it works, I'll post it later).






      All made in Gimp.

      Saturday, May 14, 2011

      SVN Branch Copy

      I was recently in the position of needing a particular SVN branch copied including history. However I didn't have administrator access on the SVN machine, and using the SVNSYNC command was going to copy all eighteen thousand revisions, mine were about fifty scattered within the last thousand. That was less than ideal.

      I devised a way to do it though, and in a few hours came up with a handy script (yeah yeah, a few hours isn't exactly a one hour hack, but downloading the SVN branch you want should be).


      Essentially the script does this:
      1. INIT a new repo at the desired location.
      2. Check out the most current branch of the old repo.
      3. Check the history of the old repo to check which revisions to sync (the changed ones).
      4. For each changed one, check it out, rsync it to the checked out new repo, and commit it to the new repo with the old log message.
      5. Finish some time later after you have made yourself a cup of tea and watched the most recent Doctor Who.

      #!/bin/bash

      # Check for proper args
      if [ -z "$1" ];
      then
      echo -e "Usage:\n$0 URL_TO_COPY_FROM URL_TO_COPY_TO" && exit 1
      fi;

      SVNFROM=$1
      SVNTO=$2

      echo "Fetching branch from: $SVNFROM"
      echo "Copying branch to: $SVNTO"

      # Set up environment.
      if [ -e tempsvn ];
      then
      rm -rf tempsvn
      fi;

      mkdir tempsvn tempsvn/download tempsvn/upload tempsvn/current
      cd tempsvn

      echo "Checking out current..."
      svn co $SVNFROM current
      HISTORY=`svn log current | grep \| | cut -d\ -f1 | sed 's/r\([0-9]*\).*/\1/' | sort -k1,1n`

      # Init the new repo at the given location.
      svn import upload $SVNTO -m ""
      svn co $SVNTO upload

      num=`echo $HISTORY | wc -w`
      echo "There are $num revisions in this branch."


      for REVNO in $HISTORY; do
      rm -rf download
      echo "-----------------------------------------------------------------------"
      echo "Revision: $REVNO"
      echo "Fetching..."
      ENTRIES=`svn co $SVNFROM@$REVNO download`
      CHANGES=`echo $ENTRIES | wc -l`
      echo "Found $CHANGES change(s)."

      echo "Change Log:"
      cd download
      LOG=`svn log -r $REVNO | grep \- -v`
      echo $LOG
      echo ""
      cd ..

      echo "Exporting..."
      rsync -a --exclude='.svn' download/ upload/

      cd upload

      IFS_BAK=$IFS
      IFS=$'\n'
      for E in $ENTRIES; do
      BEGIN=`echo $E | cut -d\ -f1`
      END=`echo $E | cut -d\ -f5- | cut -d/ -f2-`

      case "$BEGIN" in
      'A') svn add -q $END ;;
      'D') svn del $END ;;
      esac
      done
      IFS=$IFS_BAK

      if [ -e log.log ]; then rm log.log; fi;

      echo $LOG > log.log
      echo "Commiting new..."
      svn commit -F log.log
      cd ..
      done
      # Tear down environment.
      cd ..
      rm -rf tempsvn

      One slight problem though, it removes and re-checks out the branch it is copying from every time because I was getting strange errors about branches being out of date, if anyone could fix that, it would increase the speed greatly.