There are always situations where you need to display the work on your local maichine to the outside world.
In the old days, we would setup a dyndns account, forward some weird port on our firewall to port 80 on our
local machine, and give out the weird URL. Those, my friends were the dark ages.
Now we have services like Pagekite. Basically, Pagekite makes it stupid easy to
make a tunnel from your local machine to a URL on the outside world. It handles all the traffic tunneling
for you, which is really impressive. It can basically forward any port, which makes it great for SSL and
stuff.
On my local machine, I use Pow! for all of my rails development. It basically makes http://anything.dev
point to a local running rails instance. It’s been discussed before, so I won’t go into it. But, Pow! works
by reconfiguring your local DNS and making anything with .dev point to your localhost and a weird port behind
the scenes. It needs to know what the hostname is in order to know what site to use.
Since Pagekite gives you one URL (at least by default) that doesn’t end in .dev, Pow! will have no clue what
site to serve when you go to your Pagekite URL and just give you a generic welcome message. I came up with a
quick hack to work around this limitation.
Create (or modify if you have one) a ~/.powconfig file. In it, put the following:
export POW_EXT_DOMAINS=pagekite.me
Now, restart Pow! (I use Powify, so that’s just powify server restart for me). Then, create a new Pow!
site for your current app that is the same name as your Pagekite hostname.
ln -s . ~/.pow/pagekitehostname
Voila! External page serving bliss. And if there’s a situation where you need to show a different app
instead, you just change your pagekitehostname symlink to point to a different app instead. Easy!
Does anyone else find this as hilarious as I do? Just one of many pictures from the
failblog post
about people being butthurt about Instagram finally debuting on Android. It’s a great
collection of real rocket scientists, too. But that’s beside the point.
They’re all complaining that Andoird users are going to screw up their perfect walled garden.
If this is perfection, then we’re all doomed. The Instagram of today isn’t the same as the one
I left 9 months ago when I moved to Android. Since then it’s become the mainstream place to post
things. And while that’s not all bad, once you let in the masses, things tend to lose their charm.
Maybe I’m some kind of hipster, but Instagram in it’s early days really had some great pictures, or
at least was about sharing your little life moments. And at it’s heart, that’s what it is and is
still great at that. But acting like it’s the perfect community of artists is a little disingenuous.
Take a look at the Popular page at any time of the day. What do they normally consist of?
The boy band of the moment (swoon!)
Some half naked girl who’s skirting by the no nudity rules with some fairly clever hand placement because she has some “Daddy Love Me” complex (no, I’m not complaining – I’m making a point)
A teenager who could practically be a model complaining how awkward or skinny they are. (Boo hoo, I feel so sorry for you)
Random bad picture from some B level celebrity and what they had for dinner
Maybe two quality pictures of real photography in there somewhere (big maybe)
Has anyone read the comments to any of those pictures? They’re a very, very slight step up from YouTube comments.
The point is that this “community” is a bunch of BS. When things go mainstream,
that “community” is over. There’s little subgroups in there somewhere, but it’s
not what it was when it first started. Stop being some hipster remembering the
glory days and think they still exist. They don’t. It’s the real world, my
friends. And most people don’t have anything in common with most people.
I’m not saying it’s a useless app. There are great pockets of really creative people
doing a lot of great things. But let’s face it, the people who bitched the most were
most likely contributing the garbage that makes the app useless outside of those
great, creative circles.
I’ve been messing with Padrino a bit over the past couple of weeks.
There are several smallish apps that I’ve thought that Rails was a
little bit of overkill for. However, what I didn’t realize that I was
missing was the Asset Pipeline. It’s terribly useful, especially if you
tend to mix technologies together in the same app. Once you get into the
habit of using it, it gets hard to go without.
I decided to see if I could implement Sprockets directly into Padrino.
It turned out to be fairly easy to do, especially since there was
already a padrino-sprockets gem out there. Once I figured out the
proper way to put everything together, it worked perfectly.
Here is a very quick walkthrough of how to set it up with a brand new
Padrino app. Let’s create a basic Padrino application. I’ve basically
picked my usual defaults, but it doesn’t matter too much which you use.
The bonus is that any of the rendering and templates gems will be
available for Sprockets already.
Add the following to your Gemfile. This will add the padrino-sprockets
gem as well as the handlers for Coffeescript. That part’s optional, but
given the Coffeescript love in Rails 3.1 and above, you’ll probably want
it.
Run bundler and make sure all the gems are installed.
1
bundle install
Now let’s move all of the stuff in public to app/assets instead. The
default stylesheets and javascripts are fine defaults.
123
mkdir -p app/assets
mv public/* app/assets/
rm app/assets/favicon.ico
Replace app/assets/javascripts/application.js with the following. This is
basically the default rails application.js file, and just automatically
includes all other files in this directory. Putting the jquery and
jquery-ujs files isn’t necessary, but putting them explicitly in the
file makes sure that they show up before everything else.
123456789
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery-ujs
//= require_tree .
And do the same for app/assets/stylesheets/application.css
1234567
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
The last thing we need to do is put the sprockets init code into
app/app.rb config block. This just includes sprockets and
padrino-sprockets and starts it up.
1234
# Sprockets support
require'sprockets'
registerPadrino::Sprockets
sprockets
Now if you startup the server, you should be able to hit
http://site/assets/application.js and
http://site/assets/application.css, you should get the proper results.
The only issue I’ve found is that there is no easy way to override the
directories for where stylesheets and javascripts are stored. This
basically makes stylesheet_link_tag and javascript_include_tag useless.
Instead, you’ll have to hardcode the following into the head section of
your application layout.
(Note: I actually started writing this over a week ago. I can probably
rewrite some of it at this point, but I’m going to keep it written with
the feel that I just got the phone a day or two ago.)
Before I became an iPhone user in early 2008, I was rocking the Treo for
years. From the first day that I fixed a client’s problem via email
while out to dinner, I was hooked on the idea of a Smartphone. This is
obviously not a great thing for everyone, but in my particular line of
work, it was indispensable. Not that the Treo was very smart.
The iPhone 1
The iPhone 1 was an amazing device, even in it’s terribly locked up
state. This was the dark ages of no apps. If you wanted to do anything
outside of the 10 standard applications on the phone, you had to
jailbreak it, and install apps via Cydia. Being technical, this wasn’t
a huge deal to me, but it was still pretty amazing when the App Store
was released.
I work for myself, from home. There are a lot of positives about this
fact… I have no commute, I have a lot of flexibility in my schedule,
and the coffee is a lot better. But, it does have negatives as well. For
instance, it could literally be days between the times that I leave the
house. Since my job is software engineering, it also means I spend 8-10
hours a day at my desk, sitting in the chair, slowly shortening my
lifespan.
My New Home
I’ve actually heard about the standing desk movement for a long time
now, but never really gave it a lot of serious consideration. That’s
partially due to be younger, I guess. Indestructible. But I’ve kind of
made this my year to start considering some changes in my lifestyle –
and sitting all day isn’t something I really need to be doing. I like
my job, but I don’t really like that aspect of it.
When I reinstalled my system w/ Lion a few weeks back, I decided to
start using Pow! as my “web server” of choice. I’ve been spending a
lot more time in Rails over the past few months because of my day job
and wasn’t really relying on my Apache/PHP installation as much. I
delegated Apache off to port 8080 while Pow took port 80 over because it
was just too convenient.
The way I’ve always done my PHP development was just dump my projects in
subdirectories of the Apache web root (/Library/WebServer/Documents) and
leave it at that. Most of my URLs would look something like:
http://localhost:8080/some-project.
Today I was luck enough to come across this post in Assaf Arkin’s Lab
Notes site: Using Pow with your Node.js project. Long story short
is that it uses the fact that config.ru is actually a Ruby script and
uses it to make a little proxy to connect to whatever node.js server/daemon
that you happen to be running. It still requires you to start it up, but it’s
pretty convenient to have it with the same URL scheme and port 80-ness
of the rest of your projects.
I immediately decided to see if I could modify it to:
Work on my port 8080 Apache install and
Get it to automatically work with my subdirectory scheme.
First, I dropped an .rvmrc into my PHP project’s directory so I had a
php specific gemset.
12
rvm_install_on_use_flag=1
rvm --create use 1.9.2@php
Then, I installed rack into that gemset.
gem install rack
I copied in my modified config.ru (which, incidentally has the path
some-project hardcoded at the moment – I’ll clean it up later.)
[500,{},["Server is down, try $ sudo apachectl start"]]
end
end
end
runProxyApp.new
And lastly, symlinked my directory into my ~/.pow dir. Since I use
powify, I just did a powify create to basically do the same thing.
Pointed my browser to http://some-project.dev and voila! I don’t see any visible slowdowns related
to the proxy, and it works really nicely. It’s a keeper!
Wonderworks in Myrtle Beach is one of the neatest buildings I’ve seen
in awhile. Basically a building constructed to look like it fell upside
down on top of another one. The light was perfect, so I propped my arm
on a handrail and grabbed a 2+2 stop HDR.
I think I’m starting to finally get an eye for where HDR really works.
You really start to see where pictures that look great in your head
that would never actually turn out if you took the picture. I think this
falls into that category.
A couple of weeks ago, I stumbled on the Octopress
project. It’s essentially a cleaned up framework around the Jekyll
blogging “engine” that Github Pages uses (an my site). It gives it a
clean HTML 5 template, some nice plugins, etc. Since it’s essentially
just a pretty version of Jekyll, I knew that it would be possible to
swtich with minimal work and saved it for when I was on vacation and
looking for little personal projects to work on.
Switching was fairly simple. The only thing that really required work
was porting over my post_filter code from my Jekyll fork. Basically, I
added a bunch of hooks to Jekyll to allow me to run plugins before and
after rendering, and after a page was written to the disk. Hooking into
that allows me to do things like auto-post items to my archive blog, and
send out bitly links to Twitter when something is posted.
Luckily, I’ve learned a lot about ruby since I wrote that stuff, and was
now competent to do it with monkey patching the jekyll gem instead of
having to keep a fork – which made it really clean. Once that was
there, my other plugins started working immediately.
Since Octopress is just Jekyll under the hood, all of my other things
worked without any intervention. My email-to-post script works, as well
as my automatic Dropbox publishing stuff that I setup.
In fact, the only thing I had to fix was some formatting for a few posts
that have code or gists embedded in them. I’m happy with my
decision – now to just blog a little more and maybe customize the
template a little bit.