Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Edit point location (with georeferencing)</title>
<style type="text/css">
body {
margin: 0;
padding: 40px;
concern :data_routes do |options|
collection do
get 'download'
get 'list'
post 'batch_preview'
get 'autocomplete'
end
member do
post 'search'
end
require 'test/unit'
#require 'ruby-debug'
##
# Variant generator returns all possible combinations of elements of all given arrays.
# Running this gist will run the tests. For functionality only this module is needed.
module VariantsGenerator
extend self
##
require 'test/unit'
##
# Variant generator returns all possible combinations of elements of all given arrays.
# Running this gist will run the tests. For normal usage, simply copy VariantsGenerator module.
module VariantsGenerator
module_function
##
# Operates on arrays.
@specimens = Specimen.find(:all,
:include => [:ce, :otus],
:joins => "LEFT JOIN otu_groups_otus og ON otus.id = og.otu_id",
:conditions => "og.otu_group_id = 124")
named_scope :that_are_homonyms, {
:group => "sensus.label_id",
:joins => 'JOIN sensus on labels.id = sensus.label_id',
:select => "labels.*, count(distinct sensus.ontology_class_id) as total",
:having => 'total > 1'
}
When I do
bar.foo.that_are_homonyms.size # => 1000s (wrong)
Solved by adding AllowEncodedSlashes On to the httpd.conf (must be in the virtual if using virtual).
I'm stumbling here because this is a problem that does not occur in dev, but does occur in production.
Last three routes-
map.connect ':controller/:action/:id.:format',
:controller => 'proj',
:requirements => {:action => /\w*/}
@mjy
mjy / gist:1319716
Created October 27, 2011 14:37
:constraint Route matching
The problem is pretty straightforward, for a rails 3.0.10 app (upgrading form 2.3.10, which uses match style routes), ruby, 1.9.2.
I have basic routes:
/projects/1/foo/bar/1.json # controller => foo, :action => bar, etc...
/projects/1/public/foo/bar/1.json # controller => public/foo, :action => bar, etc..
I need to match the "public/foo" controller first, if no public provided just match "foo" as the controller. The format needs to be optional.
My routes.rb:
Reinstalled MacOS from scratch once more to be absolutely sure the procedure works. The list of commands after this second reinstall were these:
(Installed Xcode and Firefox first)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
\curl -sSL https://get.rvm.io | bash -s stable --ruby
brew edit proj
(Added patch referenced above)
brew install proj -s # Pay attention to -s argument, the patch won't be applied oherwiese.
brew install postgis
brew services start postgresql
@mjy
mjy / tw_api_basic_specimens.rb
Created December 1, 2020 17:12
A basic request to get specimen data back
require 'json'
require 'csv'
require 'amazing_print'
require 'uri'
require 'net/http'
project_token = 'adhBi59dc13U7RxbgNE5HQ'
URL = 'https://sfg.taxonworks.org/api/v1/'
url = URL + '/collection_objects' + '?project_token=' + project_token