Skip to content

Instantly share code, notes, and snippets.

View ktopping's full-sized avatar

Kieran Topping ktopping

  • Unbound, and self
  • Dublin, Ireland
View GitHub Profile
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
# 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]
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";
}
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";
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;
}
}
class Event < ActiveRecord::Base
...
has_many :options, :class_name => "EventOption", ...
...
end
class EventOption < ActiveRecord::Base
...
belongs_to :event
...
<%= form_for @event, :url => (@event.new_record? ? events_path : event_path(@event)) do |f| %>
...
<%= f.fields_for :options, @event.options do |f2| %>
...
<%= f2.text_field :name %>
...
<$ end %>
...
<% end %>
class Event < ActiveRecord::Base
...
has_many :options, :class_name => "EventOption", ...
accepts_nested_attributes_for :options
...
end
@ktopping
ktopping / gist:2768450
Created May 22, 2012 11:23
dynamic flip
<div id="flip" class="container">
<div class="loading" style="position: absolute; left: 100px; top: 200px; font-size: 15px;">
<div id="loading">loading...</div>
</div>
</div>
...
<script type="text/javascript">
$(function () {
--- a/jquery.flips.js
+++ b/jquery.flips.js
@@ -140,7 +140,7 @@
if( this.History.getState().url.queryStringToJSON().page !== page ) {
- this.History.pushState( null, null, '?page=' + page );
+ // this.History.pushState( null, null, '?page=' + page );