Skip to content

Instantly share code, notes, and snippets.

@jeremiaheb
jeremiaheb / prodSetup
Last active October 4, 2015 05:27
Setup script for production server
# This document specifies the steps needed to take a default ubuntu install with a main user called 'support' and
# prepare it to make a new default server.
#
# 1. Install latest ruby build from source requirements
#
# $ sudo apt-get update
# $ sudo apt-get install -y build-essential apache2-prefork-dev zlib1g-dev libssl-dev openssl libcurl4-openssl-dev libreadline6-dev vim aptitude screen apache2 postgresql git openssh-server wkhtmltopdf libffi libffi-dev nodejs
#
@jeremiaheb
jeremiaheb / RVC QAQC
Last active October 9, 2015 05:58
RVC Quality Control Methods
class newOne:
def__init__(self, new_one)
class dataEntryFile:
def __init__(self, entryFile):
self.entryFile = entryFile
def readFileToList(self):
return [line.strip().split('~') for line in open(self.entryFile).readlines()]
@jeremiaheb
jeremiaheb / Overlap Validation
Last active December 15, 2015 00:19
Validation --- Overlapping Size
// Check that a species record does not have overlapping sizes with another
// record of the same species
//get current species record info....this is the species info to compare with all the others
$.validator.addMethod("doesNotHaveOverlap", function(value, element, params){
var spp = {}
var $index = $(element).parent().parent().index();
var $thisSpecies = $(element).parent().find('.sppCommon').select2("val");
var $thisNumber = $(element).parent().find('[id$="number_individuals"]').val();
@jeremiaheb
jeremiaheb / gist:5721094
Last active December 18, 2015 03:49
create a pdf of all samples
SamplesController ---
def index
if current_diver.role == 'admin'
@samples = Sample.all
elsif current_diver.role == 'manager'
@samples = Sample.joins(:diver_samples).where( "diver_samples.diver_id=? AND diver_samples.primary_diver=? OR boatlog_manager_id=?", current_diver, true, current_diver.boatlog_manager_id ).uniq
else
@samples = current_diver.samples.merge(DiverSample.primary)
end
@jeremiaheb
jeremiaheb / gist:6124581
Last active December 20, 2015 11:39
coordinate distance
class StationLog < ActiveRecord::Base
belongs_to :boat_log
has_many :rep_logs, :dependent => :destroy
accepts_nested_attributes_for :rep_logs, :reject_if => lambda { |a| a[:replicate].blank? }, :allow_destroy => true
def self.coorDist
@jeremiaheb
jeremiaheb / gist:6186725
Last active December 20, 2015 19:58
Dashboard Tables
class Dashboard
def diver_list(current_diver)
if current_diver.role == "admin"
@boat_logs = BoatLog.all
@boatlog_divers = RepLog.group(:diver_id).count(:id)
@sample_divers = DiverSample.primary.group(:diver_id).count(:id)
@lpi_divers = BenthicCover.group(:diver_id).count(:id)
@demo_divers = CoralDemographic.group(:diver_id).count(:id)
hash_merge(@boatlog_divers, @sample_divers, @lpi_divers, @demo_divers).keys
jeremiah@jeremiah-VirtualBox:~/railsProjects/EntryApplication$ rails s
/home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
from /home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
from /home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
from /home/jeremiah/.rvm/gems/ruby-1.9.3-p392/gems/co
sample_path(Sample.find_by_field_id("55551J"))
def send_to_path(missing_field_id)
if Rails.application.routes.recognize_path(sample_path(@dashSamples.find_by_field_id(missing_field_id)))
sample_path(@dashSamples.find_by_field_id(missing_field_id))
else
benthic_cover_path(@dashBenthicCovers.find_by_field_id(missing_field_id))
end
end
@jeremiaheb
jeremiaheb / README.md
Last active January 29, 2016 19:39
nations

Motion chart of RVC data

[{"name":"epi mori_out","exploit":"pre_out","density":[[1994,0.0478],[1995,0.028],[1996,0.0478],[1997,0.0479],[1998,0.0504],[1999,0.1655],[2000,0.192],[2001,0.1785],[2002,0.1224],[2003,0.129],[2004,0.1092],[2005,0.1295],[2006,0.0638],[2007,0.0458],[2008,0.1054],[2009,0.1159],[2010,0.0816],[2011,0.0656],[2012,0.1088]],"occurrence":[[1994,0.0531],[1995,0.0469],[1996,0.0877],[1997,0.0581],[1998,0.0556],[1999,0.15],[2000,0.2274],[2001,0.2231],[2002,0.1535],[2003,0.1852],[2004,0.1613],[2005,0.1503],[2006,0.084],[2007,0.0733],[2008,0.1501],[2009,0.1747],[2010,0.134],[2011,0.0863],[2012,0.162]],"abundance":[[1994,152352],[1995,89117],[1996,152327],[1997,152610],[1998,151321],[1999,496768],[2000,576395],[2001,535960],[2002,367508],[2003,387237],[2004,327749],[2005,388860],[2006,191579],[2007,137517],[2008,316432],[2009,348012],[2010,245125],[2011,196927],[2012,326642]]},
{"name":"epi mori_in","exploit":"pre_in","density":[[1998,0.0614],[1999,0.0499],[2000,0.1739],[2001,0.1168],[2002,0.1198],[2003,0.1049],[2004,0.1619