Skip to content

Instantly share code, notes, and snippets.

View psahni's full-sized avatar

Prashant psahni

View GitHub Profile
@psahni
psahni / sphinx1
Created August 7, 2011 05:17
sphinx blog
class Country < ActiveRecord::Base
has_many :places_to_visits
end
@psahni
psahni / sphinx2
Created August 7, 2011 05:17
sphinx blog
class PlacesToVisit < ActiveRecord::Base
belongs_to :country
end
@psahni
psahni / sphinx3
Created August 7, 2011 05:18
sphinx blog
class Country < ActiveRecord::Base
has_many :places_to_visits
define_index do
indexes name,
:sortable => true
indexes about
indexes rating_no
indexes capital
indexes places_to_visits(:name), :as => :place, :sortable => true
has continent_id
@psahni
psahni / sphinx4
Created August 7, 2011 05:19
sphinx blog
Country.search params[:search], :with => {:rating_no => 5..10}
@psahni
psahni / sphinx5
Created August 7, 2011 05:20
sphinx blog
Country(params[:search], :match_mode => :all,
:field_weights => {:name => 20, :about => 10},
:with => {:rating_no => 5..10 },
:conditions => { :continent_id => 1},
:page => params[:page], :per_page => 3)
@psahni
psahni / sphinx6
Created August 7, 2011 05:21
sphinx blog
Country.search ‘India | USA’, :match_mode => :boolean
@psahni
psahni / Tinymce
Created August 12, 2011 12:44
Tiny MCE
function setup(){
tinyMCE.init({
browsers : "msie,gecko,safari,chrome,opera",
cleanup_on_startup : true,
convert_fonts_to_spans : true,
mode : 'textareas',
onchange_callback : 'myCustomOnChangeHandler',
plugins : "inlinepopups,safari,curblyadvimage,paste",
theme : 'advanced',
@psahni
psahni / map_direction_complex.html
Created September 29, 2011 16:48
map_direction_complex.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Marker Animations Loop</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type='text/javascript'>
var directionDisplay;
@psahni
psahni / location_map_complex.html
Created September 30, 2011 16:40
location_map_complex.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Marker Animations Loop</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type='text/javascript'>
// GLOBAL VARIABLES
@psahni
psahni / geodistance.html
Created October 1, 2011 14:15
geodistance example
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Center of Geodesic Polyline</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="v3_gmaps_enhance.js"></script>
<script type="text/javascript">
var EarthRadiusMeters = 6378137.0; // meters