Ever wonder why
vim loses its color schemes and settings when you are in
sudo mode? I hate it. But there’s a way to preserve your
vim settings while in
sudo -E vim some_file.txt
-E switch is the holy grail. Or you could use
sudoedit if you have it set to using
vim. And it’d have the same effect.
I bought a very beefy MacBook Air this summer. But I was frustrated with how slow the machine’s wake-from-sleep time was whenever it’s been in sleep mode for an extended period of time. For the longest time I just couldn’t figure it out. But as it turns out, it’s a new “feature” designed to make the batteries last longer.
Basically after certain number of hours, in order to save on energy, Mt. Lion saves most of the content in RAM to disk, thus making the wake up taking much much longer than desired. Here’s the blog I found with instructions to change that.
And here’s the instruction just in case. Open your Terminal via
Applications > Utilities > Terminal.app, and issue the following command:
sudo pmset –a standbydelay 43200
43200 is seconds, which is 12 hours. I almost always never leave the laptop unused more than 12 hours, so I set mine to
86400, which is 24 hours. To find out what the current setting is, issue this command:
And there you have it!
I started dabbling with building an app in Objective-C and Xcode recently. And Core Data seems to be a nice way to work with persisting data across app launches. But its learning curve is notoriously steep (Apple’s own documentation doesn’t help at all).
But Techotopia has a nice and short overview of what Core Data is and how it works in a way that’s not intimidating. But the best source for me by far is “Core Data for iOS and OS X with Simon Allardice” from Lynda.com. I’m a visual/audio learner. And the best way for me to learn is usually through a Youtube video or some clips from Lynda’s web site.
I gathered a small collection of sites on how to upgrade from Rails 2.x to Rails 3 for my last job. But we never got around to using it. But instead of throwing away the bookmarks, I thought it might be a good idea to save them somewhere more “permanent”.
One method I keep hearing from others who have done it is to make sure you have decent test coverage for your app. And then upgrade one baby steps at a time: First upgrade to the next immediate major version of Rails, and then the one after that… etc. For example, Rails 2.3.x => 3.0, and then 3.0 => 3.1, and then 3.1 => 3.2… etc. And along the way, fix your code and make sure all the tests pass.
This was a bitch to track down.
error: failed to attach to process ID 0
Basically it means Xcode is not able to attach a build of your app to the simulator. I was, however, able to build it directly on the iPhone. To solve this problem, simply do the following:
* Click on Simulator and reset the simulator by going to the “iOS Simulator” main menu and choose “Reset Content and Settings…
* Back in XCode, choose the menu
"Product" > "Edit Scheme". On the left menu panel, click on
"Run <em>Your_Project_Name</em>.app" > "Run _Your_Project_Name.app". The info display on the right should have the
"Debug Process As" radio button picked as
"Me (your-user-name)". If not, make sure you do not login as root. On Stackoverflow there are many reports of running as root will have problems
* Next, still in Xcode, go to the menu
"Window" > "Organizer". On the top menu, click on
"Projects". Go ahead and delete
* Finally, go to
"~/Library/Application Support/iPhone Simulator/6.0/Applications" and delete everything that’s in there
Restart Xcode and the simulator. And Bob’s your uncle.
Once you go git, you can never go back.
1. First, make a directory into which you want the newly minted git repo to live
cd into that directory
3. Then execute the following:
git svn clone file://localhost/Users/your-user-name/location/of/svn/repo
And that’s it!
Moving stuff from one git repo to another while keeping the history intact is a cool way to break stuff out of old repos and migrate them around. Here’s how to do it:
git clone --no-hardlinks /path/to/sourcerepository directory-to-move
# remove remote origin just so we can't break anything in the source repository
git remote rm origin
# filter for desired files
git filter-branch --subdirectory-filter new-directory-name HEAD
# move around files, etc.
# then commit
git add .
git commit -m "isolated files"
Refernece: Moving files from a Git repository to another keeping history
Before reading this article on the differences, I’d been stuffing all my
alias and other things in either
.profile files on my Macs.
Though most settings will run just fine in either file, there is an important difference between
If you need something to be executed or
source ~/.profile) as you open a new terminal tab or terminal window, stick it inside of
.bash_profile. Items in
.profile only get run once when you login.
I’m happy to report that this little printer driver that could apparently still works very well under Mountain Lion. Kudos to the author of this multi-purpose driver. It’s truly extended the useful life of my aging printer by several more years!
Update 09/17/2014: I’ve pretty much deprecated use of MacPorts and gone exclusively to Homebrew since this post. And I haven’t run into this problem since this post.
Update 12/28/2012: There’s an easier way to run PostgreSQL! Mattt Thompson has written Postgres app for Mac OSX that allows the database to run completely self-contained! Hassle-free! Last week I was trying out Sinatra and Padrino with PostgreSQL. But for the life of me, I couldn’t get PostgreSQL to run. At first I thought it was an issue with using MacPorts again. But after some googling, it seems like others who used Homebrew also had similar issues.
could not connect to database postgres: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
There are a couple of ways to deal with this. One of them is to include the PostgreSQL path on OSX’s commandline lookup chain. In your
.profile for others) file, you could add the path to the PostgreSQL binaries:
Make sure the version number on PostgreSQL matches the version you are running.
* Installation of Postgresql on MacOS X using Macports
* Installing PostgreSQL 9.0 on Mac OS X 10.6.8 via MacPorts
I was trying to create a new project with Rails 3.2.x. But every time as it runs
bundle install, I get the following error:
/Users/home_dir/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
gem uninstall and reinstalling Rails to no avail. It turns out that Ruby needs to find openssl but couldn’t find it at its preferred location. MacPorts handled all my 3rd party binary needs. But in this case, I wanted to use RVM to handle those packages for dependency reasons.
rvm pkg install iconv
rvm pkg install openssl
rvm reinstall 1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr
And that solved the issue for me.
Update 02/22/2013: The lastest version of
rvm 1.18.10 apparently will do all kinds of nice things in the background for you to solve the issue as well.
Today I decided to finally upgrade my Ruby on Rails setup at home. But upon running the
rails -v command, I ran into this error:
bash: /opt/local/bin/rails: /opt/local/bin/ruby: bad interpreter: No such file or directory
Turns out for some reason there’s another (non-working) copy of rails in my
/opt/local/bin/ directory. To fix the problem, I simply had to remove it (along with
rake and other related executables out of there).
On a related note, I also tried upgrading
rvm. But while trying to upgrade Ruby to the latest 1.9.3 with it using the
rvm install 1.9.3, I kept getting this error:
curl: (7) couldn't connect to host
Finally, what worked was this:
curl -L get.rvm.io | bash -s stable --ruby
And to bind that to rails, similarly, do this:
curl -L get.rvm.io | bash -s stable --rails
* Installing RVM
* RVM Repo