I recently got a new iPhone 4. Ok, it was my girlfriends iPhone to be exact, so it's not really new. But heres the problem I ran into. I had previously used my MacBook Pro to sync and backup her phone. Now that it was mine, I wanted to back it up fresh. So I wiped out the iPhone using the restore, but everytime I plugged it into the computer, it would automatically start syncing and restoring all of her apps! Frustrating.
But alas, there was a solution. I had to create a new library for iTunes to use separate from my girlfriends. On the Mac all I had to do was hold down the "option" key when I opened up iTunes and this allowed me to pick the directory that I wanted iTunes to use for its library. I created a new directory called "Jon's iTunes" and simply selected that. All of her stuff is not in the library so now its as if my girlfriend never even had the phone. Excellent!
AddThis
Friday, November 18, 2011
Thursday, October 6, 2011
Cygwin and Rxvt
More of a reference to myself, this is the rxvt script I use:
@echo off
C:
chdir C:\cygwin\bin
set EDITOR=vi
set VISUAL=vi
set CYGWIN=codepage:oem tty binmode title
rxvt -sl 1500 -fn "Lucida Console-12" -bg black -fg white -sr -e bash --login -i
/usr/bin/keychain ~/.ssh/id_rsa
. ~/.keychain/${username}
C:
chdir C:\cygwin\bin
set EDITOR=vi
set VISUAL=vi
set CYGWIN=codepage:oem tty binmode title
rxvt -sl 1500 -fn "Lucida Console-12" -bg black -fg white -sr -e bash --login -i
This is my keychain:
/usr/bin/keychain ~/.ssh/id_rsa
. ~/.keychain/${username}
Saturday, September 17, 2011
Upgrading Xcode
I had previously installed Xcode 3.x on my machine from the included disks I got with my Macbook Pro. However, wanting to upgrade to Xcode 4 required me to use the AppStore, which installs Xcode in a different place. Uninstalling Xcode 3.x was a snap, and here's how I did it (Remember not to be in /Developer/Library when invoking the command):
sudo /Developer/Library/uninstall-devtools --mode=all
And my output:Not sure what that error is at the top, but didn't seem like it affected anything. After that, I just removed /Developer since I'll be installing Xcode into /Applications anyways.Use of uninitialized value $pkgutil_volume_basename in concatenation (.) or string at /Developer/Library/uninstall-developer-folder line 35. Start time: Sat Sep 17 10:22:35 EDT 2011 Analyzing devtools package: 'com.apple.pkg.DashcodeLeo'... Analyzing devtools package: 'com.apple.pkg.DevDocumentationLeo'... Analyzing devtools package: 'com.apple.pkg.DevSamplesLeo'... Analyzing devtools package: 'com.apple.pkg.DevToolsDocumentationLeo'... Analyzing devtools package: 'com.apple.pkg.DeveloperToolsCLILeo'... Analyzing devtools package: 'com.apple.pkg.DeveloperToolsLeo'... Analyzing devtools package: 'com.apple.pkg.MacOSX10.4.UniversalLeo'... Analyzing devtools package: 'com.apple.pkg.MacOSX10.5Leo'... Analyzing devtools package: 'com.apple.pkg.MacOSX10.6Leo'... Analyzing devtools package: 'com.apple.pkg.OpenGLAppsLeo'... Analyzing devtools package: 'com.apple.pkg.OtherDevDocumentationLeo'... Analyzing devtools package: 'com.apple.pkg.X11DocumentationLeo'... Analyzing devtools package: 'com.apple.pkg.clangLeo'... Analyzing devtools package: 'com.apple.pkg.gcc4.0ADCDocsLeo'... Analyzing devtools package: 'com.apple.pkg.gcc4.0Leo'... Analyzing devtools package: 'com.apple.pkg.gcc4.2ADCDocsLeo'... Analyzing devtools package: 'com.apple.pkg.gcc4.2Leo'... Analyzing devtools package: 'com.apple.pkg.llvm-gcc4.2Leo'... Removing devtools files... Removing generated files... Removing Xcode Caches... find: /var/folders/pb/__7g8h0s0y5d87rh096hfd400000gn/C/com.apple.DeveloperTools: No such file or directory Removing Xcode Documentation... Removing empty devtools directories... Finish time: Sat Sep 17 10:25:28 EDT 2011 IMPORTANT: If you are going to install a previous version of the Developer Tools, be sure to restart the machine after installing.
Wednesday, August 31, 2011
Easy SSH and Cygwin
SSH-ing into a remote machine (that's running an SSH server) is super easy, but can be a major pain having to input the password over and over. This is especially true on a Windows machine. You can use putty, but I prefer using Cygwin because I get all my favorite linux utilities :) Here's how to make all that work:
Setup
source ~/.keychain/${HOSTNAME}-sh
Usage
To get be able to log in to the remote machine, simply append the contents of your local ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys on the remote machine (create the file on the remote machine if it does not exist). *If the authorized_keys file doesn't exist, create it and make sure that the permission is at least 700!
Config
If you typically ssh using another user, or want to setup an alias to be able to quickly ssh somewhere, you can configure ssh to do this. Simply vi ~/.ssh/config (create the file if it doesn't exist) and model your entries after the following:
Now to be able to ssh into server.fully.qualified.name as the admin user, simply type in:
ssh admin@server.fully.qualified.name
Setup
- Download and install cygwin with the openssh and the keychain package
- Run cygwin
- Enter in the terminal:
- ssh-keygen -t rsa
- choose some password, and enter it again to confirm
- vi ~/.bashrc and put this at the button of the file:
source ~/.keychain/${HOSTNAME}-sh
Usage
To get be able to log in to the remote machine, simply append the contents of your local ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys on the remote machine (create the file on the remote machine if it does not exist). *If the authorized_keys file doesn't exist, create it and make sure that the permission is at least 700!
Config
If you typically ssh using another user, or want to setup an alias to be able to quickly ssh somewhere, you can configure ssh to do this. Simply vi ~/.ssh/config (create the file if it doesn't exist) and model your entries after the following:
Host server
Hostname server.fully.qualified.name
User admin
Now to be able to ssh into server.fully.qualified.name as the admin user, simply type in:
ssh server
whereas before you had to type inssh admin@server.fully.qualified.name
Friday, August 26, 2011
Run Jetty Externally and Connect Remotely With Eclipse
There's another alternative to embedding Jetty inside Eclipse. We can also use Eclipse to use Maven to start Jetty for us. Then we can remotely connect and debug/manage it. It's your choice as to which option you prefer.
Configure Maven to run Jetty
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.24</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<!-- Use whatever you want the http port to be -->
<port>8080</port>
</connector>
</connectors>
<userRealms>
<userRealm implementation="org.mortbay.jetty.security.HashUserRealm">
<name>default</name>
<config>src/main/resources/jetty-realm.properties</config>
</userRealm>
</userRealms>
<!-- If you plan on changing this file during execution, turn the scan interval higher than 0 -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
</configuration>
</plugin>
Setup Start Server Command
Setup Remote Debugging
Usage
Configure Maven to run Jetty
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.24</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<!-- Use whatever you want the http port to be -->
<port>8080</port>
</connector>
</connectors>
<userRealms>
<userRealm implementation="org.mortbay.jetty.security.HashUserRealm">
<name>default</name>
<config>src/main/resources/jetty-realm.properties</config>
</userRealm>
</userRealms>
<!-- If you plan on changing this file during execution, turn the scan interval higher than 0 -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
</configuration>
</plugin>
You will need a jetty-realm.properties file and a webdefault.xml file.
jetty-realm.properties:
user1: pass1,role1
user2: pass2,role2
webdefault.xml:
Mine looks like the "JSP configuration" section
Setup Start Server Command
- Run -> External Tools -> External Tools Configuration
- Right Click Program -> New
- Name: Whatever
- Location: Browse to your mvn executable
- Working Directory: click Browse Workspace button and select ${YOUR_WEB_PROJECT}
- Arguments: jetty:run
- Click Environment
- Click New
- Enter a variable names MAVEN_OPTS and set it to "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
Setup Remote Debugging
- Run -> Debug Configurations
- Right Click Remote Java Application -> New
- Name: Whatever
- Project: ${YOUR_WEB_PROJECT}
- Connection Type: Standard (Socket Attach)
- Host: localhost
- Port: 8787
- Also click "Allow termination of remote VM". It's going to be the only way to elegantly kill your Jetty server without opening the task manager.
Usage
- Start the server using the external tools
- Start the remote debugging once the server is up
- Open up the debug perspective -> Right click the VM and click terminate to kill the server
Setting up Jetty to run inside of Eclipse
Jetty is a great lightweight server that I'm using to do both my frontend and backend development. For the focus of this tutorial, we will have a frontend slant. This tutorial in particular will cover how to setup Eclipse (Helios) to deploy my webapp to Jetty so that I can quickly see my UI tweaks and changes.
Install Jetty
Prepare Your Web Project
Prepare Jetty and Eclipse
Setup Realms for Login
Setup Ports
Usage
Right Click the server in the Servers view to manage the server. You'll be able to start, stop, restart, and debug from here.
Install Jetty
- Help -> Install New Software
- Work with: http://download.eclipse.org/jetty/updates/jetty-wtp
- Click Add
- Install Jetty and restart Eclipse
Prepare Your Web Project
- cd ${YOUR_WEB_PROJECT}
- mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
- Import your project into eclipse as an existing project
- Right click your web project and go to Project Facets
- Click Dynamic Web Module
- Select Deployment Assembly
- Make sure your Deploy Path: / is the directory one above where WEB-INF lives.
- If not, go to Add... -> Folder and select WEB-INF's parent folder (It'll be something like webapp, or WebContent).
- Now click Add.. -> Java Build Path Entries
- Select them all using shift for multiselect and click ok
Prepare Jetty and Eclipse
- Click Window -> Show view -> Servers
- Right click the servers view -> New -> Server
- Select Jetty 8 or whatever you fancy
- Server's host name: localhost
- Server's name: Whatever you want
- Server runtime environment: click the add button on the right
- Name: Whatever
- Jetty installation directory: click the Download and Install button to the right -> Accept agreement -> select a location to download
- This is important....Wait a bit for the download to complete (look at the eclipse progress in the lower right and wait for it to complete.
- When done, set the Jetty installation directory to the directory you just downloaded and installed jetty to
- JRE: Don't let this fool you, configure it to point to a jdk, not a jre.
- If you don't have one, dl it and configure it using the Installed JREs... button
- Click Next
- Select your ${YOUR_WEB_PROJECT} to add as a deployment
- Click Finish
Setup Realms for Login
- Open up etc/realm.properties and add in your favorite user and passwords (USER1: password,role1,role2)
- Save and close
- If you edit this file later to add more users, remember to clean and publish for the changes to be picked up. You do this by right clicking the server in the servers view and selecting clean. After its finished, right click it again and select republish/publish.
Setup Ports
- Double click the server you just created to open up its configuration
- Select the Overview tab
- Look for the Ports section
- Click HTTP and change to whatever port you want
Usage
Right Click the server in the Servers view to manage the server. You'll be able to start, stop, restart, and debug from here.
And thats's pretty much it. Super easy and straightforward.
Thursday, August 18, 2011
No Time for SQL Date
We have a stored proc (ugh) that is called from within Hibernate. We pass in values to this stored proc using the type, java.sql.Date. The stored proc then does comparisons against some date column against the date object we passed in, but we were noticing that the time portion was being ignored! The answer was simple and frustrating, java.sql.Date ignores time (should have read the javadocs sooner) :( We had to instead use java.sql.Time. I would have much rather preferred we NOT use stored procs. A few quick benchmarks and noticed that the stored proc to get a count versus a Hibernate projection was on average four times slower. What can you do when the client loves stored procs?
http://download.oracle.com/javase/6/docs/api/java/sql/Date.html
http://download.oracle.com/javase/6/docs/api/java/sql/Date.html
Subscribe to:
Posts (Atom)