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
@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.
@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 / 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: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'])
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
SomeList.find(:all, :conditions => ["some_id = ?", some_object.attribute_of_some_object.id])
SomeList.where(some_id: some_object.attribute_of_some_object.id)
@jmscholen
jmscholen / Project Euler Problem 1
Created July 18, 2014 18:34
Project Euler Problem 1
CODE
******************************
------------------------------
def value_returned(number)
if is_divisible_by?(number)
return number
else
return 0
end
@jmscholen
jmscholen / gist:e492589fe3f8c627e5bb
Last active August 29, 2015 14:04
CodeKata 1: SuperMarket Pricing
Some things in supermarkets have simple prices: this can of beans costs $0.65. Other things have more complex prices. For example:
three for a dollar (so what’s the price if I buy 4, or 5?)
$1.99/pound (so what does 4 ounces cost?)
buy two, get one free (so does the third item have a price?)
The exercise is to experiment with various models for representing money and prices that are flexible enough to deal with these (and other) pricing schemes, and at the same time are generally usable (at the checkout, for stock management, order entry, and so on). Spend time considering issues such as:
does fractional money exist?
when (if ever) does rounding take place?
me
@jmscholen
jmscholen / gist:10267795
Created April 9, 2014 13:03
Racing Horse Testing HW
#not started