Detect Multiple Displays in Adobe AIR

June 13th, 2011

To find the resolution of multiple monitors, you can loop through the Screen.screens array and then get the bounding rectangle of each monitor screen. Typically AIR counts from left to right (0 index the right most monitor) but I haven’t tested this on every monitor configuration.

import flash.display.Screen;

for(var i:int = 0; i < Screen.screens.length; i++)
{
    var x = Screen.screens[i].bounds.left;
    var y = 0;
    var width = Screen.screens[i].bounds.width;
    var height = Screen.screens[i].bounds.height;
}

Firebug Tutorial: Debugging CSS

February 18th, 2011

A few of my students at a work and some other friends often come to me with CSS debugging questions. I always turn to Firebug, and amazing Firefox add-on that let’s you analyze everything about a webpage from DOM, source HTML, CSS, Javascript, AJAS request, etc.  This little tutorial will demonstrate the basic techniques I use to figure out why the styling of elements isn’t quite working how it aught to.  Of course, to do this you will need Firefox and Firebug add-on.

Once you have this, navigate to the web page in question, for this example let’s look at: http://www.sapethemape.com/debugcss.html.  Here you will notice the bullet list is very spaced out and not displaying from left to right. Hmm, I remember setting #nav to display:inline, I wonder why its not working. Let’s open up the Firebug console by clicking on the little bug icon in the bottom right corner of Firefox. Now click on the Inspect button, this will be the blue mouse pointer on top of a rectangle in the top left of the Firebug window.  After this is clicked, hover over the word “Home.” Notice how there is a blue border around that element and the firebug window changes and displays information about that element.

Notice that the #nav ul li element only has padding: 30px.  If you hover over the div #nav element, this is where the display:inline was. To make a list display from left to right, the LI elements must have the style display:inline.  Thanks to the inspect tool, we were able to see what CSS styles were assign to the element in question.

With Firebug, we can also do live edits to make sure we are correct. Double click on the area just to the right of padding: 30px and a new text box should pop up. In here type “display: inline”. Notice how Firebug auto-completes for you, as well as updates the webpage with the changes. Now the page should have a horizontal navigation bar below the header. Note that the line number of the CSS declaration is displayed in the information panel. This is very helpful in finding the actual line in the code to update.

You can also click on the HTML to the left of the style information to view that elements information. Click around and you should start to get a feel for the power of Firebug. Try adding some borders to the navigation bar, adjusting the margin and padding and see how everything is effected.

USC Employee Benefits – Tuiation Assistance Guide

January 6th, 2011

I work at the University of Southern California and one of the perks is tuition assistance.  As an employee, you are eligible for 6 credits/semester of undergraduate level courses and 4 credits/semester of graduate level courses. Children or dependents get free tuition and a spouse/domestic partner gets 50% off tuition.  I have outlined the steps to take if you would like to start taking courses, but have not been accepted into a degree program. This is called Pre-Admit or Limited Status.  You can take up to 16 credits this way that will count toward your degree.  Most of the people reading this will be interested in graduate school. The curve ball here is you are taxed on any tuition assistance over $5250 per year.  This equates to roughly 3 credits at USC.  The only way to get around this is if the course is job related.

All you really need to do is fill out the appropriate forms and turn them in.  Below is a step by step breakdown of what forms you need to fill out and where to turn them in. I wish someone had laid it out like this for me, so I passing my knowledge along.

Here is what you do for limited status, pre-admit (once you are admitted all you need to do is fill out the Tax For Graduate form and the Staff-Admitted Student form and you can take whatever you want):

  1. Fill out the Pre-Admit form and get the appropriate departments heads to sign it (details in form).
  2. Fill out the Limited Status Form to register for classes.
  3. If it’s graduate work, you need to fill out the Tax For Graduate form and see if you can get it to be Job Related or not. If the class can be signed off by a supervisor as job related, you do not have to pay taxes on the tuition. Turn that for into Payroll.
  4. Take the Pre-Admit to USC Benefits (USC Credit Union Building 2nd floor)
  5. Take the Limited Status Form to the Registrar Office, and they will enroll you in the class.

Forms:
Limited Status Registration: Form_4005a_Limited_Status_Form

Pre-Admit: TAB_PreAdmission.pdf
Job Related Audit: http://www.usc.edu/dept/Benefits/forms/tuition_assistance/TAB_Audit.pdf
Tax For Graduate: http://ais-ss.usc.edu/empldoc/forms/forms.html (all the way at the bottom)

Reference:
USC Tuition Assistance Benefit: http://www.usc.edu/dept/Benefits/edu_assistance.html
USC Tuition Assistance Forms: http://www.usc.edu/dept/Benefits/forms_tuition.html

Remove Google Everything Sidebar Firefox Greasemonkey Script

May 6th, 2010

There are a few people out there who do not like the new Google everything sidebar. I personally find it to be distracting. Since there is no way to turn that feature off, I made a Greasemonkey script to do it. The script is very simple. I removes the sidebar by default, but adds a button that lets you show or hide the sidebar. This script is hard coded with the element ID’s so it will only work as long as they keep that the same. I will try to keep it up to date. This only works on Firefox but I will see about making one for Chrome. Enjoy!

Install Google Remove Everything Sidebar

Adobe Air MP3 Shaker (Shuffle)

February 7th, 2010

I like iTunes, it’s a good media player. But I got some MP3s that are not part of my iTunes library, an old backup. I don’t want ALL of them to be automatically imported into my iTunes library just so I can listen to them. And There is a lot, over 1000. I wanted to select the directory, and hit play and have it go through so I can listen. If any that caught my attention and were not already in my library I could import it. On Windows, I would just use WINAMP. But I could not find a Mac version of WINAMP. I wanted something light, simple, just to play a directory of MP3s.

A few years ago, my first Adobe AIR project was an MP3 player. It was pretty much full featured: volume control, track progress, skinning, etc. I wanted something a little simpler, cleaner. I had a free Saturday, and I made a new one. Based it off of the Apple iPod Shuffle, 2nd generation. It is very simple to use. When it opens, select a directory of MP3s (it only plays MP3s), and be patient if its a directory with thousands of MP3s it will take a moment to load. A window will come up with a list of all the MP3s, double click one to play, or hit the play button, or next. You can close the windows and just have the player up, it shows the name of the song if ID3 tags are available. The reason I call it “MP3 Shaker”: if you shake it (drag it left and right really fast) it will shuffle to another song (just like the new iPods). Click the green light on the top right to close.

As always, its open source. Right click anywhere on the player and select view source. Enjoy!

Please upgrade your Flash Player This is the content that would be shown if the user does not have Flash Player 9.0.115 or higher installed.

$5 Laser Pointer Pistol

February 3rd, 2010

I was thinking about a gift for a friend, and she really likes guns (military brat). And after making my Light Up Space Poster, I figured I could use the left over parts and make a little light up toy gun. Of course, make a Laster Pointer gun! I got some basic ideas from Blue Ray Laser Gun at HackNMod. To make a long story short, I found that the Dollar Store is the best place to get toy guns. To my surprise, they also have super cheap laser pointer key chains. So the 2 main components, were about $1.29 each (yeah, they should call it the buck-twenty-nine store now). Here is the complete list of parts and tools:

  • Toy Pellet Gun – Dollar Store, $1.29
  • Cheap Laser Pointer Keychain – Dollar Store, $1.29
  • Wire
  • Push Button Switch (Trigger)
  • 150 Ohm Resistor
  • 9 Volt Battey
  • 9 Volt Batter Clip – Radio Shack
  • Solder and Soldering Iron
  • Hot Glue and Glue Gun
  • Philips Screwdriver

The gun I got, had 3 screws, and popped open. Its very cheap plastic, so be careful pulling it apart. Same with the laser pointer. I used a $10 Black And Decker Laser Pointer for one version (before I found the one at the Dollar Store) and that is in an all aluminum case, so you will need a file to cut it about 1 cm from the base of nose. The Black And Decker was noticeably brighter and a higher quality laser.

One the diode is removed, we need to bypass the switch. Solder the negative batter leas to the side of the switch closes to the diode.

It took me a while to find the best place to solder the positive side, with the resistor to the diode. For the $1 pointer, its on the back, for the $10 its on the some bronze plating.

I used a resister just to be safe and to get he voltage down to about what the device was created for. Using a 9V was done for convenience only. It was easy to stick that sucker in the handle and connect it with the battery clip. The $10 pointer could take the 9V without the resistor, so if you want more power don’t use the resistor.

Be careful soldering the switch up! I ruined one holding the soldering iron to the lead for too long and melted the plastic housing. So do not linger with the soldering iron when soldering the switch.

I had to cut/melt away some of the gun for the switch to fit through when the gun was placed back together. The plastic is cheap enough, it is easy to manipulate. Remove bits so you can fit the batter, switch, and laser diode in the barrel. Secure the switch and diode with generous amounts of hot glue. Try to make sure the diode is aligned so it aims true (mine is a little up and to the right). I also wrapped my 9V in tape so it didn’t rattle around when the gun was placed back together.

That should do it. Now, aim, fire, and avoid shooting your eye out!

Fine Art 102 Design Gallery

December 20th, 2009

Get the Flash Player to see this content.

Mac OS X on a Dell Vostro A90 (Mini 9)

August 19th, 2009

mac vostro openOver the summer I had a little argument with a coworker about the “Mac tax.” I was telling him that a Mac uses pretty much the same hardware you will find in a “PC” (that word, PC, used in that context annoys me because PC is Personal Computer, so technically as Mac is a PC, but marketing prevails I guess) but Mac’s are a lot more expensive. So in an attempt to prove my point, I tried to install Mac OSX on to my HP laptop. After about 15 tries, all I could get it to do was finish the installation. Never got it to boot. I gave up, moved to California, bought a MacBook Pro because I wanted a Mac and the USC Bookstore was having a sale.

Very happy with my MacBook Pro I did not pursue ihackintosh any more. Then after the netbook craze, I found a lovely Mac OSX netbook compatability chart and noticed everything works on the Dell Mini 9/Vostro A90 (they are the SAME computer). A Mac netbook, that would be cool!

I waited, trying to save up some splurging money. Meanwhile I helped two of my friends pick out netbooks for themselves (both were HP Mini 10, one with solid state and one without), which made me want to buy one. On top of that I found some Dell discounts from a friend, and I went to the Dell Outlet and bought a Vostro A90 with 16GB SSD and Ubuntu for $280 delivered.

Since I am going to be hacking and all that, I figured I would buy a nice retail copy of Mac OSX 10.5.6 (which I also got at the USC Bookstore, seeing as they sell it for $99).

With my new-to-me netbook and fresh retail copy of Mac OSX, I went home and stayed in on a Friday night, to bump up my geek cred!

This is not meant to be a full tutorial, there are many many online, but more of a checklist of items needed and the guide I followed, and some road blocks. And a little review of my Mac Vostro A90 at the end.

I only had one issue worth noting. After I booted off of the DellMiniBoot 8.02b1 and swapped the disc for the retail Mac OSX install disc it took a few tries for the OSX installer to load. The Vostro didn’t recognize the install disc right away after I swapped the discs. I had to wait about a 15 count before I hit ENTER on the boot screen after I put in the retail Mac OSX install disc. So if you get stuck and the intaller will not load, just keep trying! It took me about 10 minutes of fiddling before I go it to load the installer. Other than that, follow the guide to the letter, they do a very good job of outlining what you need to do.

UPDATE: To get to the BIOS hit 2 at boot up, and hit 0 to get to the boot menu.

UDPATE: ***For sleep to work you must deselect usb wake from sleep and usb legacy mode in bios***

mac vostro closed

Checklist:

I have been using my Dell Vostro for about 2 weeks now. I took it on a trip to Chicago, and it played about 4 hours of TV shows from a USB stick on the plane ride. Which is pretty good considering its a refurb and I know that batter is not at 100%. The computer is very small though. The screen is nice, but the resolution is only 1024 x 600. Most web pages look fine, and you kinda get used to it. It does have a VGA port if so you can hook up an external monitor. I got it to play relatively smooth streaming video from Hulu at 1280 x 1024 full screen. The biggest issue I have with the computer is the keyboard layout. The quote ( ‘ ) is not in the normal place by your right pinky, but down below the period next to the spacebar. So I hit enter instead of ‘, which is really annoying when you are IMing.

Most of the time I use it at work, I have Synergy installed on my work Windows XP machine, and SynergyKM installed on the Mac Vostro. Mich is great for testing websites. Just copy the URL and move my mouse down to the Mac Vostro and paste it in and see how it looks! Aside from that, everything works, runs quite smooth, and quiet. Overall, I am really happy with it.

Moving SQL Server Database to GoDaddy

August 3rd, 2009

Recently a client asked me for some help moving his website from his own server to host on GoDaddy. The website was created in VB.NET and connected to a Microsoft SQL Server Express 2005 Database. Unfortunately there is no EASY way. There SHOULD be. It should not be this difficult and time consuming to migrate a SQL Server not running on GoDaddy to a GoDaddy hosted SQL Server. I even tried connecting directly to the GoDaddy database but it failed. I don’t think they like remote connections. So here is how I did it.

Needed: SQL Management Studio (the full version, not express). Included with SQL Server 2005 full version. This is needed for generating the scripts to easily create the structure on the new GoDaddy database.

Notes: GoDaddy will not accept a .bak file that was not created by them. I tried…

Step 1: Create SQL Server database on GoDaddy. Try to make this the GoDaddy database the same name as your original database, and the same user name. I do not think it is required, but will make everything a lot easier. Once it’s done you will want to have the GoDaddy SQL Server web admin open.

Step 2: Export and import the structure. Open up SQL Server Studio and find your original database, right click the database -> Tasks… -> Generate Scripts… A wizard will pop up. Select your database, and select all the stuff you want to export, I did everything. Might want to skip the user the source and destination do not match. You will see an option to either save it to a file or new query window. I did a new query window. You can then copy and paste big collection of SQL queries into the GoDaddy Query Analyzer in the database web admin.

Step 3: Export source data from SQL Server Studio to CSV. There are a few ways to do this. Right click the database -> Tasks… -> Export… Select your source database, and on the destination screen select the destination to be a flat file. OR you could also select all the results from a table using a SELECT * FROM table query and then right click on the results window and click Save Results As… This will the results as a CSV in your favorite location. Both methods will only do one table at a time. I could not find a way to export all the data at once, so if you have a lot of tables with a lot of data this will be very time consuming. Maybe higher an student or nephew to do it.

Step 4: Clean CSV. Be mindful that though this will export as a CSV, it will not escape the fields in QUOTES. So if a cell has commas in them you will have to add quotes around them manually after you export it. Make your hired nephew look through all the CSV’s also, or make some clever regular expression. Also, the GoDaddy SQL Server web admin will give you errors when the fields don’t match up, so you could fix as the errors come up.

Step 5: Import CSV to GoDaddy. Back in your GoDaddy SQL Server web admin, there is a CSV File Importer that will import data for a specific table. Remember, if you have foreign key constraints, you will get an error if the parents are not uploaded first, and a child is pointing to a row that does not exist. So upload the most general tables first, then all the look up tables so all the foreign key restraints are satisfied.

That should be able it. Hopefully you experienced minimal errors. And don’t forget to update you web.config file’s SQLConnectionString to point to the new database. The new data source will be the full name of the database you are connected to in the GoDaddy SQL Server web admin (i.e. dbname.db.12345.hostedresource.com).


<connectionStrings>
		<remove name="SQLConnectionString"/>
		<add name="SQLConnectionString" connectionString="Data Source=dbname.db.123456.hostedresource.com; Initial Catalog=database_name; Persist Security Info=True;User ID=database_user;Password=database_password;Connect Timeout=200; pooling='true'; Max Pool Size=200"/>
</connectionStrings>