Skip to content

Instantly share code, notes, and snippets.

Avatar

Jon Gautsch jgautsch

View GitHub Profile
@jgautsch
jgautsch / ecto_postgres_fulltext_search_querying_example.ex
Created Apr 25, 2019 — forked from pmarreck/ecto_postgres_fulltext_search_querying_example.ex
How to set up postgres fulltext search triggers, index, and tsvector column on Elixir/Phoenix, with Ecto querying, including ranking and sorting by rank
View ecto_postgres_fulltext_search_querying_example.ex
defmodule YourAppName.Search do
# ...
@doc """
Queries listings.
"""
def query_listings(query, current_user) do
default_scope = from l in Listing, where: l.draft == false or l.user_id == ^current_user.id, order_by: [desc: l.updated_at], limit: 50
id = _try_integer(query)
View README.md
@jgautsch
jgautsch / App.js
Created Jul 29, 2015
Defining client routes for react-routes in ruby, so they can be checked both on the client and server
View App.js
import $ from 'jquery';
import React from 'react';
import Router, { Route } from 'react-router';
import App from './components/App';
// Recursively builds the nested react components that represent the routes
var buildRoutes = (routesObj) => {
return routesObj.map((route) => {
if (!route.name || !route.path || !route.handler) {
console.error('route.name (:as), route.path, and route.handler must all be defined.');
@jgautsch
jgautsch / ko_bh_checkedUniform.js
Created Jun 28, 2015
jquery.uniform.js checkbox knockout binding handler
View ko_bh_checkedUniform.js
ko.bindingHandlers.checkedUniform = {
init: function(element, valueAccessor) {
ko.bindingHandlers.checked.init(element, valueAccessor);
$(element).uniform();
},
update: function(element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
if (value === null) {
element.indeterminate = true;
}
@jgautsch
jgautsch / map.rb
Created Aug 22, 2014
the Map script for the NPI dataset MapReduce
View map.rb
# ###########################################################
# Configuration
# ###########################################################
# Load all Gem and ENV dependencies
require 'rubygems'
require 'bundler/setup'
require 'dotenv'
Dotenv.load
require 'require_all'
@jgautsch
jgautsch / small_npi.csv
Created Aug 22, 2014
small NPI sample, part of the greater NPI dataset
View small_npi.csv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 1.
"NPI","Entity Type Code","Replacement NPI","Employer Identification Number (EIN)","Provider Organization Name (Legal Business Name)","Provider Last Name (Legal Name)","Provider First Name","Provider Middle Name","Provider Name Prefix Text","Provider Name Suffix Text","Provider Credential Text","Provider Other Organization Name","Provider Other Organization Name Type Code","Provider Other Last Name","Provider Other First Name","Provider Other Middle Name","Provider Other Name Prefix Text","Provider Other Name Suffix Text","Provider Other Credential Text","Provider Other Last Name Type Code","Provider First Line Business Mailing Address","Provider Second Line Business Mailing Address","Provider Business Mailing Address City Name","Provider Business Mailing Address State Name","Provider Business Mailing Address Postal Code","Provider Business Mailing Address Country Code (If outside U.S.)","Provider Business Mailing Address Telephone Number","Provider Business Mailing Address Fax Number","Provider First Line Bus
@jgautsch
jgautsch / classes.rb
Created Aug 22, 2014
classes.rb, The Classes that the NPI MapReduce script depends on
View classes.rb
# ###########################################################
# Data Processing
# ###########################################################
module DataProcessing
class TaxonomyCache
def initialize
@@specialties = Taxonomies::Specialty.all[0..-1].group_by(&:taxonomy)
@@specialties.each do |k, v|
@@specialties[k] = v.first
end
@jgautsch
jgautsch / mongoid.yml
Created Aug 22, 2014
mongoid.yml for NPI MapReduce
View mongoid.yml
development:
sessions:
default:
database: geocoded_providers
hosts:
- 0.0.0.0:27017
raise_not_found_error: false
options:
pool_size: 35
@jgautsch
jgautsch / Gemfile
Created Aug 21, 2014
Gemfile for NPI MapReduce job
View Gemfile
source 'https://rubygems.org'
gem 'dotenv'
gem 'rake'
gem 'faker'
gem 'pry'
gem 'mongoid'
gem 'geocoder'
gem 'activesupport'
gem 'require_all'
@jgautsch
jgautsch / params.rb
Created Jun 12, 2014
Schedule Setup Wizard params
View params.rb
params = {
weekly_recurring_schedule: {
length: 20,
color: "red",
user: 34,
locale: 11,
restriction: "Open to public",
name: "Dr ABC's appointments"
days: {
sunday: [
You can’t perform that action at this time.