Skip to content

Instantly share code, notes, and snippets.

View pangkalizer's full-sized avatar

Allan Andal pangkalizer

  • Sydney, Australia
View GitHub Profile
class UsersController < ApplicationController
respond_to :html, :json
def index
@json = User.all.to_gmaps4rails
respond_with @json
end
end
@pangkalizer
pangkalizer / google.maps.OverlayView
Created May 14, 2013 00:37
TemplateOverlay.prototype = new google.maps.OverlayView;
var popupTemplate = '<div id="business-card-${id}" class="business-card business-card-${type}"><div class="business-card-close"><a href="#">close</a></div>' +
'<div class="business-card-header"><h4 class="business-card-title"><a href="/${friendly_uri}">${company}</a></h4></div>' +
'{{if logo}}<div class="business-card-logo"><a href="/${friendly_uri}/"><img src="${logo}" alt="${company} logo" /></a></div>' +
'{{else}}<div class="business-card-logo-empty"></div>{{/if}}' +
'<div class="business-card-content">' +
'{{if tagline}}<div class="business-card-desc">${tagline}</div>{{/if}}' +
'<div class="business-card-address"><a href="/${friendly_uri}"><p class="business-card-address">${street_address} ${suburb} ${state}</p></a></div>' +
'{{if has_phone}}<p class="business-card-phone"><a class="ph-${id}" href="">View Phone Number</a></p>{{/if}}' +
class Foo < ActiveRecord::Base
has_many :bars
belongs_to :baz
include IndexingHandler
indexed_associations :bars, :baz
end
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

# Run with: rake environment elasticsearch:reindex
# Begins by creating the index using tire:import command. This will create the "official" index name, e.g. "person" each time.
# Then we rename it to, e.g. "person20121001" and alias "person" to it.
namespace :elasticsearch do
desc "re-index elasticsearch"
task :reindex => :environment do
klasses = [Place, Person, Caption]
@pangkalizer
pangkalizer / clear_postfix_email_queue
Created January 3, 2013 02:00
clear postfix email queue
for i in `mailq|grep '@' |awk {'print $1'}|grep -v '@'`; do postsuper -d $i ; done
@pangkalizer
pangkalizer / es.sh
Created December 2, 2012 02:36
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.0.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share