This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event < ActiveRecord::Base | |
... | |
has_many :options, :class_name => "EventOption", ... | |
... | |
end | |
class EventOption < ActiveRecord::Base | |
... | |
belongs_to :event | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flushThis(id){ | |
var msie = 'Microsoft Internet Explorer'; | |
var tmp = 0; | |
var elementOnShow = document.getElementById(id); | |
if (navigator.appName == msie){ | |
tmp = elementOnShow.parentNode.offsetTop + 'px'; | |
}else{ | |
tmp = elementOnShow.offsetTop; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use mySociety::GeoUtil qw/national_grid_to_wgs84/; | |
use CAM::DBF; | |
my $filename = $ARGV[0]; | |
my $dbf = CAM::DBF->new($filename); | |
# Double-check the data is as we expect. | |
my @fieldnames = $dbf->fieldnames(); | |
die if $fieldnames[0] ne "PC1" || $fieldnames[6] ne "X" || $fieldnames[7] ne "Y"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use mySociety::GeoUtil qw/national_grid_to_wgs84/; | |
while (<>) { | |
my @x=split(/,/); # split csv | |
my ($pc, $east, $north) = ($x[0], $x[10], $x[11]); | |
$pc=~s/\"//g; # remove quotes around postcode | |
my ($lat, $lng) = national_grid_to_wgs84($east, $north, "G"); # "G" means Great Britain | |
print "$pc,$lat,$lng\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mod_rewrite preamble: | |
RewriteEngine On | |
RewriteBase /shop | |
# The following rule omits anything that actually really maps to a file or folder. | |
RewriteCond %{SCRIPT_FILENAME} !-f | |
RewriteCond %{SCRIPT_FILENAME} !-d | |
# Anything that's not the above, we route to index.php with the path in "readablePath" | |
RewriteRule (.*) index.php?readablePath=$1 [L,QSA] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
production: | |
solr: | |
# Kieran's laptop's (obfuscated!) ip address. | |
# I'm lazy. I usually ascertain it from http://whatismyip.com/ | |
hostname: 86.00.00.000 | |
port: 8980 | |
log_level: WARNING |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[kieran@localhost myapp]$ # Build docs | |
[kieran@localhost myapp]$ rake doc:app | |
[kieran@localhost myapp]$ # The following line shows you where to browse to | |
[kieran@localhost myapp]$ # in order to view your docs | |
[kieran@localhost myapp]$ echo "Find your docs here: file:///$PWD/doc/app/index.html" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test "sunspot available" do | |
begin | |
# Search for instances of "String". The String class will always | |
# exist, so I use it in order to make this test simpler. It then | |
# has no dependency on my application classes. | |
s = Sunspot.search(String) {} | |
rescue | |
assert false, "Cannot connect to solr server #{Sunspot.config.solr.url}\n#{$!}" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query.adjust_solr_params do |params| | |
params[:"f.#{Sunspot::Setup.for(MyModel).dynamic_field_factory(:custom).build(:my_field).indexed_name}.facet.prefix"] = my_leading_str | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[kieran@localhost myapp]$ script/console | |
Loading development environment (Rails 2.3.2) | |
>> c = Content.new(:xml => '<content><field1>abc</field1><field2>def</field2></content>') | |
>> c.save | |
=> true | |
>> Content.search.results | |
=> [] | |
>> Sunspot.commit | |
=> {"responseHeader"=>{"status"=>0, "QTime"=>33}} | |
=> Content.search.results |