Skip to content

Instantly share code, notes, and snippets.

View nerboda's full-sized avatar

Eliathah Boda nerboda

View GitHub Profile
@nerboda
nerboda / calendar.rb
Created November 29, 2020 18:06
Calendar
class Calendar
attr_reader :start_date, :taken
TIMES = ['09:00:00', '09:45:00', '10:30:00', '11:15:00', '12:00:00', '12:45:00', '13:30:00', '14:15:00', '15:00:00', '15:45:00'].freeze
def initialize(start_date, taken)
@start_date = start_date
@taken = taken.join(',')
end
@nerboda
nerboda / get_nth_weekday_of_month.rb
Created November 12, 2020 22:29
Get nth occurrence of selected day for particular month in Ruby (for finding holidays)
def get_nth_weekday_of_month(n, day, month, year)
first_day_of_month = Date.new(year, month, 1)
if first_day_of_month.wday <= day
days_to_add = day - first_day_of_month.wday
else
days_to_add = (7 + day) - first_day_of_month.wday
end
first = first_day_of_month + days_to_add.days
@nerboda
nerboda / glassroots-data-spec.md
Created July 10, 2018 22:51
Glass Roots Data Spec

GlassRoots Data

GlassRoots Data is a map based visualization tool for gaining high level insights on the feasability of broadband projects in rural and urban neighborhoods throughout Colorado.

Data layers include Census Data at the State, County, Zip Code, Census Tract, Census Place, and Census Block Group levels for both 2010 and 2016. We then overlay that with Broadband Speed Test data from both data.colorado.gov and fcc.gov, allowing you to quickly scout out unserved or underserved areas where census metrics like population density, percentage of remote workers, median income etc. might expose as being ripe for broadband development projects.

Minimum Viable Product

In it's current form, the app doesn't provide the full feature set outlined in our value proposition and will require 1-2 months development in order to get to a minimum viable product that provides value to our target customers: Small ISPs and Municipalities.

@nerboda
nerboda / promises.js
Last active May 2, 2018 21:09
Promises
function MyPromise(action) {
this.status = 'pending';
this.value = undefined;
this.thenCallbacks = [];
this.onCatch = undefined;
this.onFinally = undefined;
this.then = function(callback) {
this.thenCallbacks.push(callback);
@nerboda
nerboda / elastic_search_initializer.rb
Created March 22, 2018 22:58
Elastic Search Heroku Config Initializer
if Rails.env == 'production'
url = ENV["BONSAI_URL"]
transport_options = { request: { timeout: 250 } }
options = { hosts: url, retry_on_failure: true, transport_options: transport_options }
Searchkick.client = Elasticsearch::Client.new(options)
end
@nerboda
nerboda / elastic_search_query.rb
Last active October 28, 2020 03:46
Elastic Search Query
class << self
def query(params)
listings = self.active_record_search(params) # filter by other parameters first
# return right there if search is blank
return listings.page(params[:page]) if params[:search].blank?
# otherwise pass already filtered set to elastic search for further filtering
listing_ids = listings.pluck(:id)
self.elastic_search(params, listing_ids)
@nerboda
nerboda / hwm_website_speed_optimization.md
Last active March 11, 2018 07:47
HWM Website Speed Optimization

HWM Website Speed Optimization

Benchmarks

NOTE: When doing a speed test for horizonwebmarketing.com, there's a redirect to the https://www version of the site, so load times will be slower for the http or non-www version. When testing the https://www version directly, load times are slightly faster. The benchmarks below are based on the https://www version given that that's where almost all traffic will be directed.

Page statistics

  • Page size - 1.9MB
  • Requests - 130
@nerboda
nerboda / query_mysql_db.rb
Created December 28, 2017 19:50
MySQL2 Ruby Example
require 'mysql2'
CLIENT = Mysql2::Client.new(:host => "localhost", :username => "root", :database => 'aoc_wordpress')
select_rows = <<-QUERY
SELECT * FROM artists LIMIT 100;
QUERY
CLIENT.query(select_rows)
@nerboda
nerboda / serp_optimizer.md
Last active February 9, 2018 01:41
SERP Optimizer

SERP Optimizer

The tool presents KPI data from Google Search Console by URL for each of the pages on your site. It discovers opportunities to improve click through rates and decrease bounce rate by looking for high impression pages that are performing poorly despite their rankings. It provides a simple way to manage your websites Title Tags and Meta Descriptions, and to track the influence changes to them have on your KPIs over time.

Features

  • Analyze your sites KPI data (impressions, clicks, CTR, average position etc) by url or keyword
  • Receive alerts about opportunities to improve your content's appearance in SERPs
  • Assign keyword targets for pages to help focus your SERP optimization efforts
  • Assign page targets for keywords to help eliminate competing pages
  • Plan changes to titles/meta descriptions with scheduled tasks
@nerboda
nerboda / osha_city_sites.html
Created November 30, 2017 00:37
Mobile Friendly Styles for OSHA City Sites
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-38847374-13', 'auto');
ga('send', 'pageview');
</script>