Skip to content →

diego.org Posts

Adobe Flex ComboBox Cell Padding

Recently I was trying to figure out how to make the padding in the cells of a <mx:comboBox> smaller than the default. This proved to be much harder than I thought. But I eventually found a solution.

Here is what the default looks like:

Here is the code I came up with:











And here is the final output:

 

Comments closed

Open Link in Safari

Here some sample code showing you how to open a link in Safari when clicked on in your UIWebView. The method shouldStartLoadWithRequest is a delegate method that is called when a link is clicked on. You can override the method and tell it to open in Safari.

– (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType; {

NSURL *requestURL = [ [ request URL ] retain ];
// Check to see what protocol/scheme the requested URL is.
if ( ( [ [ requestURL scheme ] isEqualToString: @”http” ]
|| [ [ requestURL scheme ] isEqualToString: @”https” ] )
&& ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) {
return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
}
// Auto release
[ requestURL release ];
// If request url is something other than http or https it will open
// in UIWebView. You could also check for the other following
// protocols: tel, mailto and sms
return YES;
}
Comments closed

PostgreSQL Sequences

Today I was trying to figure out the name of a sequence in the db, so I could add it to my hibernate mapping.  I usually use pgAdmin, but that wasn’t an option today.  After some searching, I eventually figured it out, but it took me awhile…

Get a list of all Sequences in a schema:
select sequence_name from information_schema.sequences where sequence_schema=’public’

Get a list of all tables:
select table_name from information_schema.tables where table_schema=’public’

 
Get the next sequence value for sequence: foo_seq
SELECT setval(‘foo_seq’, 42);

 
Update the sequence to 42 for sequence: foo_seq
select nextval(‘foo_seq’);

 
Note if you are looking for more info on sequences check here: Sequence-Manipulation Functions

Comments closed

iPhone App: KQED Daily Schedule

My first iPhone application was posted on the Apple App Store today.  The KQED Daily Schedule

 I’m always interested in what is currently playing on KQED, my local NPR affiliate.  So I created an application that download the Radio and TV schedule and diplays it on the iPhone.  It tells you the program, time, description if available and link to more information.  I hope you enjoy it.    You can download it for FREE from the App Store here:  KQED.app

More info and screenshots can be found on the iPhone App Page

This application is not affiliated with KQED.  It uses RSS feeds provided by KQED  (http://www.kqed.org/community/rss/) and NPR (http://www.npr.org/rss/) to create an iPhone experience.

Comments closed

How To Rename an iPhone XCode Project

I recent created a new iPhone XCode project based off of one of the samples provided by Apple. Beause of this the XCode project was called AppleSample.xcodeproj and it built an app called AppleSample.app. I wanted to rename the project and give it my own name. It’s not as easy as it sounds. Here are some instructions which are based off some instructions I found here (http://aplus.rs/cocoa/how-to-rename-project-in-xcode-3x/)

  • Copy/rename the folder into new name
  • Get inside the new folder and rename the .pch and .xcodeproj files. Example rename AppleSample.xcodeproj to MyCoolApp.xcodeproj — and — rename AppleSamplePrefix.pch to MyCoolApp_Prefix.pch
  • Delete the build folder. (Using the finder)
  • Open .xcodeproj file in text editor, like TextMate or TextWrangler. That’s actually a folder, which contains 4 files (you can also right-click and do Show package contents, which will reveal the files)
  • Open project.pbxproj in text editor and replace all instances of the old name with the new name. Be careful not to do a find an replace. Since the default name was AppleSample, there were several references to: AppleSampleAppDelegate.h and AppleSampleAppDelegate.m. You do not want to replace these unless you also rename that file.
  • Open .pbxuser where is your user name. Then repeat the previous step by renaming. I’m not sure if this is necessary. You may even be able to delete this file? But changing this file worked for me.
  • Load the project file in XCode, do Build/Clean all targets

After following these steps, I was able to open the project and build it to the simulator and the device.

I had one additional problem that I came across later that required a fix. When I finially built the application for “deployment” to the App Store, I had problems signing the code. I complained that it couldn’t find the Certificate for “Scott Anguish”. I looked in the build settings and couldn’t find reference to this name. So again I opened project.pbxproj inside of MyCoolApp.xcodeproj and found 2 instances of this line:

CODE_SIGN_IDENTITY = “Scott Anguish”;

I replaced both of them with the correct code signing identity and it worked!

UPDATE: Check out this bash script which does it for you automatically:
renameXcodeProject.sh

Comments closed

XCode 3 Debugger and Screenshots

I’ve been doing some iPhone development with XCode recently and had problems using the debugger on the device (not the simulator) and also with taking screenshots.

When installing an application on to the device, the debugger would say:

"Failed to start remote debugserver for MyApp.app"

I search around looking for a solution. In a thread somewhere, someone suggested reinstalling the SDK from scratch. I had first installed the SDK about a year ago when it came out. I then installed several updates over it. For whatever reason, that cause problems.

After reinstalling the latest SDK from Apple website, the debugger worked perfectly! And I was able to take screenshots from the device.

Comments closed

Print Perl Path

I was having issues with one of my Perl programs and needed to look at the path. To do so, you can print your Perl path like:
perl -e “print qq(@INC)”

Or if you want to print your path of a running program to the log:
warn “path=” . qq(@INC) . “nn” Comments closed

Error 51: Unable to communicate with VPN subsystem.

Occasionally I see the following error when starting the Cisco VPN client on my mac.

The error message reads:
Error 51: Unable to communicate with VPN subsystem.
Please make sure that you have at least one network interface that is currently active and has an IP address and start this application again.

To fix this problem, simply run the following command from the Terminal:
sudo /System/Library/StartupItems/CiscoVPN/CiscoVPN restart

Running a command with sudo, means you’ll need to be an administrator and it will prompt you for your password.

Comments closed

MacOSX user Disappeared & Restored

The other day, I opened my MacBook Pro a few hours after closing the lid and putting it to sleep.  It wouldn’t wake from sleep.  I tried several things to get it to try and wake up, but had no success.  This has happened a couple times in the past, and I usually just hold down the power key to restart it.  So that is what I did.

When it started back up and loaded the login page, I noticed something strange, my user was missing.  I have 4 user’s registered on my computer and now only 3 of them were showing.  So I logged in as one of the other users who an admin.

Upon login, I could see that my user’s account still existed on disk:  /Users/doug  When I went to the System Preferences, I did not list my user.  I wasn’t sure what was wrong.

I began searching through the file system and found there is a file for each user in /var/db/dslocal/nodes/Default/users/  Example:

/var/db/dslocal/nodes/Default/users/doug.plist

I opened up doug.plist and found that it was a binary file.  I could read some of the text in there and saw some mention of “Kernel” and other thing that suggested a stacktrace or dump.  I opened up the plist for another user and found that it was standard XML.  

So I copied the doug.plist from my Time Machine backup and replaced it with the one on my laptop.  I rebooted and my account was restored.

I’m not exactly sure what happened, but the moral of the store is:

  1. Create a Time Machine Backup
  2. Have at least one other Admin user on your computer you can login to if all fails.
Comments closed

Habanero Poppers

Habanero Poppers
Habanero Poppers

I’m a big fan of Jalapenos Poppers and Habanero Chili Peppers, so I figured I’d try to create some Habanero Poppers.   The result was a success.  Here’s my recipe.

INGREDIENTS

  • 2 Dozen Habanero’s
  • 12 ounces of cream cheese
  • 8 ounces of shredded Cheddar cheese
  • 1 cup milk
  • 1 cup flour
  • 1 cup bread crumbs
  • 2 quarts oil for frying (I used Olive)

DIRECTIONS

  1. Mix the cream cheese and the shredded cheddar cheese in a mixing bowl.
  2. Cut the tops off the Habanero, and remove the veins and seeds.  This will allow you to stuff the cheese in.
  3. Stuff the cheese into the Habanero’s.  I had the best luck when I rolled the cheese into a cylinder about the same size as the Habanero hole and stuffed it in.
  4. Pour the milk in one bowl and the bread crumbs in a separate bowl.
  5. Dip the Habanero’s in the milk and then roll them in flour to coat them.  Let them dry for 5 to 10 minutes.
  6. Next, dip the Habanero’s back in the milk and then roll them in the breadcrumbs.  Let them dry for 5 to 10 minutes.
  7. Repeat the process of dipping the peppers into milk and then breadcrumbs about 2 more times or when the Habanero’s are fully coated.  Don’t worry.  Dipping them back in the milk will not remove the previous coating of breadcrumbs.
  8. Heat a medium sized skilled with oil.  I used olive oil, but any cooking oil is OK.  (About 365 degrees F).
  9. Deep fry the Habanero’s for about 2 to 3 minutes.  They should be golden brown.  Remove and place on paper towel to dry and drain off excess oil.
  10. Enjoy!

TIPS

  • Wear rubber gloves.  The Habaneros are hot and can burn your eyes.
  • Use reduced fat cream cheese.  It’s hard to taste the difference.
  • Don’t skimp on the dipping.  It’s time consuming, but worth it.
  • If you’re a wimp, you can substitute the Habanero’s for Jalapenos.
  • If you’re a wimp, make sure you have a big glass of milk on hand when eating the peppers.
Comments closed