Skip to content

Instantly share code, notes, and snippets.

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
@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
@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: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 / 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 / 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 / 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
#