Why don’t I post some videos that I watch from time to time?
Here’s a 2005 interview with Paul Graham, founder of Y Combinator.
Also, check out his essays if you haven’t already.
Why don’t I post some videos that I watch from time to time?
Here’s a 2005 interview with Paul Graham, founder of Y Combinator.
Also, check out his essays if you haven’t already.
Javascript popups still have their uses. Here is a tiny snippet that one can use to create Javascript popup-windows in a Ruby on Rails application in an elegant fashion.
In your application.js (or whatever .js-file you prefer) include this:
$('a[data-popup]').live('click', function(e) { window.open( $(this).attr('href'), "Popup", "height=600, width=600" ); e.preventDefault(); });
Then, in your views add the data-popup
-attribute to the link_to
-helper:
<%= link_to( 'Open Popup-Window', popup_window_path, 'data-popup' => true ) %>
This is basically taken from [here](http://stackoverflow.com/a/8828841 “”). I have just added two extra parameters to window.open()
.
I am currently working on a small prototype application that requires my rails app to store and process geospatial information. Basically, I am storing and querying longitude/latitude coordinates.
I have been working on projects that had similar use-cases before, but when I joined everything was set up already. Also, usually it was PostgreSQL with PostGIS. This time though, I had to do it myself and with MySQL.
So, since other people might have the same idea, I figured I’d put a few code snippets here so you can get started quicker.
First, here’s my Gemfile:
source 'https://rubygems.org' gem 'rails', '3.2.11' # you should update this to 3.2.13 now! ;) gem 'mysql2' gem 'spatial_adapter', :git => "https://github.com/descentintomael/spatial_adapter.git" gem 'geokit-rails3' # ... some other gems here
This is how a migration might look like (I don’t think you still need the ENGINE=MyISAM line with a current MySQL version):
class CreatePoints < ActiveRecord::Migration def change create_table(:points, :options => 'ENGINE=MyISAM') do |t| t.string :name t.column :lat, :decimal, :precision => 15, :scale => 10 t.column :lon, :decimal, :precision => 15, :scale => 10 t.timestamps end end end
I also added indexes on both decimal-fields.
And here is a bit from my model including two simple queries.
class Point < ActiveRecord::Base attr_accessible :lat, :lon, :name acts_as_mappable :default_units => :miles, :default_formula => :sphere, :distance_field_name => :distance, :lat_column_name => :lat, :lng_column_name => :lon def self.nearest_points( lat, lon ) Point.within( 10, :origin => [lat, lon] ).order( "distance asc" ) end def self.at_point?( lat, lon ) Point.within( 0.02, :origin => [lat, lon] ).order( "distance asc" ).first end # ... etc. end
Check out the geokit-rails3 README on Github for some examples.
I hope I just saved someone an hour or so of googling.
Scott Pullen has submitted an update to the Ember.js demo-app I wrote a few weeks ago. He updated the Ember-sources and made a small change. If you haven’t seen my tutorial click here.
Usually when I decide to “quickly set up something on a server” it takes much longer than anticipated. Not so with sSMTP.
Basically it’s a simpler way to send emails from the the commandline. In my case with Gmail. Check out this article on how to set it up. I have also combined it with Logwatch and Fail2Ban and it worked immediately.
In the case of Fail2Ban just one extra line in the config-file was needed:
mta = ssmtp
All of this was inspired by this post (via Hacker News).
Just a picture I took a few weeks ago in Hamburg. This was taken with my phone. It shows a bit of the harbor on a cold January morning. The light was great. There is ice on the water.
Open the image in a new window to see the picture in high resolution.
Let’s say you have a collection with 10.000 records in your database and you want to put them all in a large array for some reason. With Rails, you can write something like this:
records = Thing.all
Now you can go get yourself a coffee, because the content of all your records will be output to the console window and it will do so for a while.
Here’s the quick tip: If you want to suppress the output, simply do something like this:
records = Thing.all; 0
Problem solved. Easy, but I didn’t think of it immediately..
I attempted to update XCode using the App Store app yesterday and was presented with the message “To update this application, sign in to the account you used to purchase it.”. This message however did not point to the real reason why it didn’t work.
What I did was disabling Spotlight Search indexing some time ago, because it affected performance. Turns out, the App Store app uses Spotlight search and in order for XCode to update, it needs to be turned on.
To turn Spotlight Search on, open a terminal and type the following:
sudo mdutil -a -i on
Also make sure you are signed in to your iTunes-Account.
Ruby 2.0 was released today, on it’s 20th anniversary. For an overview of features check this article here and this presentation here. (Both urls linked to from the announcement page.)
Because I was working a lot in the (Rails-) backend lately, I decided to find myself a small frontend-centered side-project that I could work on in my spare time. Because I think that Yehuda, Tom and the others are clever people, I chose Ember.js.
The idea was a small application for salespeople. And now, after a week, I am actually pleasantly surprised how little code I had to write to make it work.
However, I did have to really do a lot of digging through their docs, the ember-sources and ask silly questions on StackOverflow and in the emberjs irc-channel, in order to figure out how to make my app work. There isn’t too much good documentation available now, it seems. Even the Peepcode-tutorial (naturally) didn’t answer all my questions.
So I thought it would be good idea to make a little code-walkthrough video myself. To, hopefully, help the next guy or girl who wants to learn Ember.js.
So yes, here it is:
UPDATE: Contact me if you want a high resolution version of that video. I’ll send you a link.
Ha. I seem to sound a little Russian when I speak English!
And here’s the source-code if you want to download it.
I am obviously a total Ember.js-noob, so don’t take my word for it that I am doing things properly. (I am probably not.) Consider this a little snapshot of one man’s learning progress.
Perhaps I will write an update or make an updated video to show you new things I have learned.
I also have some links with regards to ember.js here.
EDIT: (March 26th , 2013)
I have reverted a merged pull request, because it introduced a bug. Example-App should work fine now.