Monday, February 27, 2012

LA Public Library Overlays, Take 1 redux

I wanted to start a project that would try increase the use of the local LA County library system. To do so, I thought it would be awesome to get more people to stop buying books online and instead checkout books from their local library.

I still need to work out some kinks, but I created a github repo that will overlay any links (with ISBN-10 urls -- a small subset) to purchase a book from Amazon to re-direct to the LA County Library website search.

For instance, say there are links in the page like the following:

City of Dragons by Robin Hobb
O’Reilly’s Information Architecture for the Web (This was highlighted by the librarian when I was asking about API access :P)

Right now there is nothing special about the links. You can hover over them with your mouse to see that they point to Amazon.

To see the code in action

  1. [If using chrome: Drag this link onto the current tab][With Safari, drag it onto your Bookmarks bar, then click on the bookmarked link][Other browsers: TBD]: COLA Public Amazon Highlight

    Assuming that the github js link works, if you click on the link, and then re-hover over the previous links you will see API calls to the LA County website.

  2. Hover your cursor over the above Amazon links
You should see something like: Which link will direct you to the Los Angeles Colapublic Library page to reserve the book.
Login, place the book on hold and the library system will email you when the book is available to pickup at your local library.

To create a bookmarklet and get this functionality across the web, you can add the above javascript: link to your browser bookmarks. Bookmarks with javascript code are called bookmarklets then when you want the overlay functionality, simply select the bookmark(let)

Technically, there is nothing special in this iteration, but just a general idea.

Note:This blog was originally published on tumblr, but there where problems running 3rd party javascript to create in-page divs.

Thursday, November 20, 2008

Blog Code Formatting

Note (2012): This post was about a previous webdesign, and no longer applicable.

I finally added code formatting to my blog. I used a completely 'client side' javascript library called syntaxhighlighter, hosted on Google Code. Note that I'm currently linking javascript directly from their web facing SVN repository, so I'm not sure how stable it is (but hosting it on googlepages didn't seem to work (they disallow js linking I believe)).

Although it is a technology blog, I thought I posted more code about stuff. I only seem to have two posts where I actually put up any code (But maybe that's because it was horribly formatted?), and they now both have pretty Java and XML formatting:

Maybe one of these days, I'll find use for a blog again. The whole concept of blogging seems so dead.

Wednesday, April 02, 2008

My Yahoo! Answers Science Post

I am my dad's personal Yahoo! answers person when it comes to things science and physics. So when I received a question on the dual nature of light and matter, I wrote him back a nice long (LFP!) email in answer. I thought I'd share.

Question:

Sound travels in waves and needs an "ether" for transmission.
Light is also a wave but doesn't need an ether. Is light in space "wave" or "particle"? because when light bends do particles bend or this this one of the examples of light as wave?

Answer:

Sound is a pressure wave. It is the compressing of molecules. It is the compression that is the sound.

Light is a wave of electromagnetic fields, fields in this case being force representations. The light wave is a constant of nature in which a electric force changing will produce a magnetic force which will cause an electric force in a stable, repeating way traveling forward. There are other places where electricity creates magnetic forces and vice versa, but they are not stable and not self-contained.

When material is present, those electromagnetic forces exert themselves into a single point, which is what is classically defined as a particle. Light in space is then always a "wave", since that is the way it propagates itself and travels.

When light is in a perfect vacuum, its speed is constant at c. When light is traveling through a material, the speed is slower than c, based on a calculation related to its "index of refraction". This quantity is the change at which an electromagnetic wave will move forward while remaining self-contained and stable.

The 'index of refraction' is the change in velocities between material boundaries causing an apparent difference in the way that light is 'seen' (this is velocity that have direction now, not speed which is a directionless quantity). This is the reason you put a pencil in a glass of water, it seems to fracture or "refract" at the air-water boundary since the speed of light in each material is different.

So light never "bends". What light bending is usually described that way because it is passing through things in which the velocity of the electromagnetic wave is different. This is the case of seeing mirages of water when the light from the sky bends up; the index of refraction of the air is temperature dependent.

Monday, March 10, 2008

how i saved my windows xp installation with knoppix

so its true. the difference between a 'digital native' and a 'digital immigrant' is the amount of information that they contribute to the world. I absolutely hate having to wade through google searches to find an answer to my problems, so I try to post here about some of my tech adventures (even though it might be nerdy) hoping that one day a spider would come and crawl/index it and provide answers to people for the same questions I couldn't find answers to!

So I tried to upgrade the ATI Radeon drivers on my Windows machine for my old video card (thinking it would improve performance! hah! no.) but I could not get Direct3d to work for my ol' Radeon 9500. After the 26 or so re-boots fiddling with the hardware, the hardware connections and the hardware drivers, something finally happened to my Windows XP OS partition. It got fried.

I tried to boot up, but after the BIOS loaded I would get the error: Windows XP could not start because the following file is missing or corrupt: \WINDOWS\SYSTEM32\CONFIG\SYSTEM You can try to repair this file by starting the Windows Setup program from original floppies or boot from CD-ROM. Select 'r' at first screen to repair

I did searches all over the internets to fix my problem, that of a corrupt WindowsXP SYSTEM registry, which caused my XP installation to not boot. Microsoft has a whole knowledge base article about this exact issue! Well, thats fine... just load up your version of XP from a CD (or floppy) and hit 'r' to repair, just like it says. Wait, except I have a SATA drive... and there is no native SATA drivers for those on the Windows XP CD! So Windows XP install CD does not see a valid drive with Windows on it to repair!

Damn.

I love this install of Windows, this drive has been with me since pre-Service Pack 1 days. Lots of tweaks (which caused the problem?) and lots of customization has made it unlike any other windows install I've used over the years. I wasn't about to just re-image the drive after backing up the data.

So I gave Knoppix a try. For those that don't know what it is, it is a Linux Live CD (meaning you run Linux from RAM and swap space) and supposedly contains lots of windows repair utilities. Booting it up, it had no problem seeing the SATA drives, booted into the OS and everything was fine. I was using the newest version, version 5.1.

I found the backup system registry 'hive' files at /System Volume Information/_restore/[Text String] and copied them to the desktop. Renamed them to be the operational one, but the Knoppix disk would not let me write back to the hard drive!

There is a problem with NTFS. The NTFS file system is a Microsoft proprietary OS whose protocols have been reverse engineered by the open source community. There are a couple different ways to make the NTFS formatted hard disk available.

mount -t ntfs /dev/hda1 /mnt/c

Which is the approximate default command in the /etc/fstabBut this command only allows the NTFS disk to be read, since the mount command (even with the -rw option) doesn't allow NTFS partitions to be written to. Everywhere on the internets talks about this, that there could be problems with corruption if users were allowed to write directly to the file system using the mount command. So I couldn't fix the registry hive this way.

So I went into alternate mounting techniques to allow the partition to be written to. Supposedly there is a program called CaptiveNFS (captive-ntfs) that is available on older versions of Knoppix, but wasn't availiable on 5.1. So I downloaded Knoppix 3.6, only to find out that CaptiveNFS wasn't supported any longer and did not work with Windows XP SP2. Shucks, again.

The problem, of course, was information overload.

Of course, Knoppix 5.1 came with utilities to write to an NTFS partition, it is noted as being the distro that allows users to recover windows partitions! There are two utilities: ntfschdsk, ntfsmount that do what I need: check the disk for corruption (and auto-correct things if it can) and mount the NTFS partition to write.

Running ntfschdsk I received:

CHKDSK is verifying indexes (stage 2 of 3) Deleting index entry .DEFAULT in index $I30 od file 30. 73 percent completed.

So at least one entry was corrupt on the disk. Not a problem though, remount the partition with ntfsmount command. Then went into the previous registry save state and copied the following files DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM from /System Volume Information/_restore/[Text String] (where Text String is some naming auto-archiving naming convention) to the /windows/system32/config directory, overwriting the corrupted hive files.

Reboot the machine, the machine reads in the non-corrupted backup Registry Hives. Instant (instant being over the course of 3 days) success!

Hopefully, someone finds this post on the 5th page of google searches and finds what they need.

Originally written 12/10/2007 - finally posted 03/10/2008!

The Internets Is Scary Sometimes

Sometimes, you think that you are covered on the internets (all of them!), but then I get an email like this to my primary account:

As a courtesy, we are notifying you that XXXXXX users have found the following accounts for you:

   Flickr tmarthal on Flickr
   Digg tmarthal on Digg
   MySpace birddog on MySpace
   Picasa marthaler on Picasa

If you would like to make these accounts private, please
change the privacy settings on the original network and
XXXXXX will update its search results to reflect your changes.

To find your friends on XXXXXX, signup now.

I removed the company that sent the email, not sure that I want to encourage this type of email and account harvesting.

The point is, that someone, somewhere has correlated my different accounts on my various networks to my single email signon. Someone, somewhere knows my that the articles dugg on digg are associated with the pictures that I post on flikr! So, when I don't post anything, they can check my pictures to find out what I was doing!

They missed twitter, delicious, slashdot, facebook and this blog though! And all of my troll accounts! Thats tood to know that there is some anonymity!

Tuesday, February 05, 2008

Spring Framework Sample Main Method

So my desk-mate* and I were having a conversation about an upcoming coding project, and he remarked how nice it was for someone, somewhere to post a complete sample on their blog for the spiders to index, so that he can find it. So I thought I would also, pay it forward and hopefully someone in like 2012 comes by and needs a sample main method using the spring spring framework for application level dependency injection.

Everyone out there seems to have used the MVC and deploying spring based apps in a web server WAR file. Except for this link: Levarage Spring Web development with Offspring. [Offtopic: it uses classes in the com.offspring.* package, like the band's website!] It uses a simple bean file and a main method really close to the following snippet to instantiate (that's my new favorite word) the application using the spring context**:

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.blogger.tmarthal.listener.SampleListenerInterface;

/**
 * simple class showing the a listener interface
 * starting listening
 */
public class simpleParserAndStorage
{
  /**
   * The spring context main method
   * @param args
   */
  public static void main(String[] args)
  {
    if (args.length != 1) {
      System.out.println("Usage: java parser.java ");
      System.exit(1);
    }

    String springContextFile = args[0];
    System.out.println(springContextFile);
    ApplicationContext context = new ClassPathXmlApplicationContext(springContextFile);

    // the listener just starts listening
    SampleListenerInterface listener = (SampleListenerInterface) context.getBean("listener");
    listener.startListening();
  }
}

Now, the wiring, or what sort of implementation is the SampleListenerInterface? This is where dependency injection comes in. Depending on the type of thing you are listening for (or what the example is doing) the implementation class is going to change. The main method is going to remain the same, the bean wiring takes place in the xml file, rather than in the application logic.

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
 <beans>
    <bean id="listenerHelper" class="com.blogger.tmarthal.listener.SampleListenerHelperInterfaceImpl">
    </bean>

    <bean id="listener" class="com.blogger.tmarthal.listener.SampleListenerInterfaceImpl">
      <!-- location of what it is listening on, passed in as constructor arguments -->
      <constructor-arg><value>localhost</value></constructor-arg>
      <constructor-arg><value>10001</value></constructor-arg>
      <!-- and it refers to a different class that would help it listen -->
      <constructor-arg><ref bean="listenerHelper"/></constructor-arg>
    </bean>
 </beans>

So, assuming that there is a Interface implementation of SampleListenerInterfaceImpl and SampleListenerHelperInterfaceImpl in the classpath, then the spring framework will call the listen method of the SampleListenerInterfaceImpl class!

Pretty neat. Hopefully someone, sometime stumbles upon this example trying to get into writing a non-WAR spring framework application, and this post will be helpful to them. I wish I found something like this first. :)

* no, not my office mate: we share a desk
** i know the code formatting sucks

Friday, November 09, 2007

Dolphins Make Me Happy

Lately, I'm not sure if its part of a seasonal migration or something, but there seems to be a lot more dolphins in the water. And they seem to be a lot more playful. Meaning, they swim under/close to us when we are surfing and jump and twist out of the water pretty frequently. I should get pictures. They also seem to show up when we are surfing right when a huge set is about to roll in, and the dolphins always seem to ride the set waves while I try to survive the overhead+ sets.

So anyways, read this today: http://www.msnbc.msn.com/id/21689083/

Basically dolphins showing altruistic tendencies towards a surf and protecting him while in the ocean. So they know we're out there. I wonder if they hear me when I jump in the water and screech back to them. :)

</happy>

Monday, November 05, 2007

double-tap it

So, oftentimes on my iphone I would unlock it and my ipod controls would come up. I thought it was a bug for a long time, since the controls went away so fast... but it is a feature!

It turns out you can access the iphone ipod controls while the phone is locked or in a different menu than the ipod interface by double-tapping the home button! So, double tapping to wake goes directly to the ipod interface pause button... handy when people are trying to talk to you and you're listening to music! You can also double tap from any interface and the ability to fast-forward/rewind/pause comes up. Neat-o.

Are undocumented features like this a reason to upgrade your firmware? This is only a iphone 1.1.1 September 2007 update feature or something.

Thursday, October 25, 2007

I've got the whole internet in my hands

Following up the xkcd.com "comic", a sweet idea to map the IP address range and their owners into a 2d map (where all adjacent values are grouped together), some bored people over at an email consulting company mapped out the IP addresses and activities using actual CAIDA 'whois' data in a scalable google map. CAIDA (The Cooperative Association for Internet Data Analysis) collected the data as seen in the huge png:

Huge CAIDA PNG

The scalable 'google maps' like viewing of the Hilbert Table is here:

http://thewholeinternet.wordtothewise.com/

I should be all Blog2.0 and post this as a trackback, but they don't have the option.

It is pretty neat to take data that you normally don't visualize, in this case the assigned DNS IP ranges of organizations and put them together in a way that can make the lay-person understand something new. In this case, you can see the companies that 'formed', or at least were the first to embrace, the internet and register whole top level domains! Meaning, of the 4-256 values in a typical IPv4 these companies have a whole first number to themselves.

For example, The Computer Science Corporation 'CSC' owns the whole 20.*.*.* address range. Crazy.

Thursday, September 13, 2007

updated blog license

i know that i'm not a major player in the content creation business (I just know those kids in Japan are stealing my blogs, translating them, and calling them their own!!) but I put the license at the bottom here, the Creative Commons Attribution 3.0 United States License. That's what the Creative Commons tells me when I select Yes to "Allow commercial uses of your work?" and "Allow modifications of your work?". So, all of you people re-mashing my sweet blog via your Pipes or Mashups, then feel free. =)

I also reduced the number of posts on the front page (soon my xmlrpc blogpost will have scrolled off) and added the archival links at the bottom. Enjoy.

Creative Commons License tmarthal
This work is licensed under a Creative Commons Attribution 3.0 United States License .