Skip to content

Instantly share code, notes, and snippets.

View jmscholen's full-sized avatar

Jeff Scholen jmscholen

  • IOU Financial
  • Johns Creek
View GitHub Profile
RAILS_ROOT = File.dirname(File.dirname(__FILE__))
RAILS_ENV = "staging"
RUBY_PATH = "/home/rails/.rvm/rubies/ruby-1.9.3-p392/bin/ruby"# path of rails user
def generic_monitoring(w, options = {})
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 10.seconds
c.running = false
c.notify = {:contacts => ['team'], :category => 'Start if processing running false'}
end
@jmscholen
jmscholen / gist:e4995b061d305cddf023ad2b8a7c6747
Last active July 28, 2016 17:54
Setting up MySQL dB connection within Ruby Script and Rails app
require 'yaml'
require 'mysql'
@dbconfig = YAML.load(File.read('/home/dev/app/config/database.yml'))
@con = Mysql.new(@dbconfig["#{env}"]['host'],
@dbconfig["#{env}"]['username'],
@dbconfig["#{env}"]['password'])
@jmscholen
jmscholen / gist:36794a6cc12a7399cd66ae8c68a63836
Created July 28, 2016 15:17
Scraping Info from HTML page
#example of scrapping information such as a listing from a website
#that list results in a container for each 'match' of the search criteria.
require 'nokogiri'
website = "www.example.com"
scrapped_info = Array.new
doc = File.open(ARGV[0]) { |f| Nokogiri::HTML(f) }
doc.css('.result-container').each do |x|
@jmscholen
jmscholen / gist:3e9011408227e6dd1f0b55b9be714e42
Last active July 4, 2019 05:11
Rails Arel Complex Multi Join Query
def self.get_docs(some_input, required_docs, optional_docs, base_id = nil)
base_req = self.get_parameters_from_request(some_input)
user_department_id = some_input.user_department.try("id") || -1
doc = Document.arel_table
dept = Department.arel_table
dept_rule = DepartmentRule.arel_table
dept_code = DepartmentRuleCode.arel_table
debt_state = DepartmentRuleState.arel_table
@jmscholen
jmscholen / _vue-rails.md
Created August 15, 2019 14:28 — forked from przbadu/_vue-rails.md
Vue js and Rails integration

Setup Rails and Vuejs

  1. Generate new rails app using --webpack flag
rails new myApp --webpack=vue

Note:

  1. You can use --webpack=angular for angular application and --webpack=react for react.