Skip to content

Instantly share code, notes, and snippets.

View scottrice10's full-sized avatar

Scott Rice scottrice10

  • Hopper
  • Austin, TX
View GitHub Profile
[
{
"jmhVersion" : "1.32",
"benchmark" : "com.rallyhealth.mongo.v13.AkkaStreamsMongoCollectionBench.findFromPublisher",
"mode" : "thrpt",
"threads" : 10,
"forks" : 1,
"jvm" : "/Users/scott.rice/.sdkman/candidates/java/8.0.292.hs-adpt/jre/bin/java",
"jvmArgs" : [
"-Xmx350m",
[
{
"jmhVersion" : "1.32",
"benchmark" : "com.rallyhealth.mongo.v13.FutureMongoCollectionBench.aggregate",
"mode" : "thrpt",
"threads" : 10,
"forks" : 1,
"jvm" : "/Users/scott.rice/.sdkman/candidates/java/8.0.292.hs-adpt/jre/bin/java",
"jvmArgs" : [
"-Xmx2G",
@scottrice10
scottrice10 / 100chairs.js
Created March 14, 2015 20:45
100 chairs
//Problem: variation of Josephus problem
// Take a second to imagine that you are in a room with 100 chairs arranged in a circle.
//These chairs are numbered sequentially from One to One Hundred.
//At some point in time, the person in chair #1 will be told to leave the room.
//The person in chair #2 will be skipped, and the person in chair #3 will be told to leave.
//Next to go is person in chair #6. In other words, 1 person will be skipped initially, and then 2, 3, 4.. and so on.
//This pattern of skipping will keep going around the circle until there is only one person remaining.. the survivor.
//Note that the chair is removed when the person leaves the room.
//
//Write a program to figure out which chair the survivor is sitting in.
@scottrice10
scottrice10 / protractor.conf.js
Created December 22, 2014 22:25
Example protractor.conf.js
var globalTimeout = 120000;
/***************************************************************
** set configs for protractor tests
**
***************************************************************/
exports.config = {
//directConnect: true,
@scottrice10
scottrice10 / apacheDevelopmentAngularJSMacbookSetup.py
Last active August 29, 2015 14:05
This script allows an AngularJS app with html5mode set to true to refresh and navigate correctly with an Apache web server on a MacBook. Specifically, the script 1. creates an .htaccess files in every git repo containing an index.html file, 2. creates sym links from all webapp directories in a local git directory to the apache document root, and…
# all apache files need writeable permissions for this script to run
import sys, inspect, os, shutil
home = os.path.expanduser("~")
top = home + '/git'
apacheRoot = '/Library/WebServer/Documents/'
#first remind user to have proper permissions on /etc/apache2/
var = raw_input("\nScript requires that /etc/apache2/ is writeable. Running 'sudo chmod -R 777 /etc/apache2' will accomplish this. Enter 'y' to proceed.\n")
if var != 'y':
sys.exit(0)
@scottrice10
scottrice10 / elasticsearchNGramMapping.sh
Created September 10, 2013 01:01
Here is a mapping using an ngram filter enabling Elasticsearch to search on word fragments, which is necessary for autocomplete. An alternative/addition to using an ngram filter (not shown here) would be to use a shingle filter, which additionally searches on phrase fragments.
curl -XPUT 'localhost:9200/doctors_index' -d '
{
"settings": {
"analysis": {
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": ["standard", "lowercase", "kstem", "edgeNGram"]
}
@scottrice10
scottrice10 / elasticsearchShingleFilterMapping.sh
Created September 10, 2013 01:00
An interesting problem from StackOverflow: How to preserve the special character in a token, while also tokenizing the individual special characters. Example: "H&R Blocks tokenized as: "H", "R", "H&R", "Blocks" With the help of this blogpost, a possible solution:
"settings" : {
"analysis" : {
"filter" : {
"blocks_filter" : {
"type" : "word_delimiter",
"preserve_original": "true"
},
"shingle":{
"type":"shingle",
"max_shingle_size":5,
@scottrice10
scottrice10 / elasticsearchMappingNPIData.sh
Created September 10, 2013 00:58
Here is a mapping I used to index ~75,000 health provider documents from npiapi.com, a web service providing NPI health provider records in json. Lines 4 and 5: Per recommendations on the Elasticsearch Google Group and by a gist written by Shay Bannon about peak indexing performance, I set a high number of shards and 0 replicas to increase index…
curl -XPUT 'localhost:9200/doctors_index' -d '
{
"settings": {
"number_of_shards": 16,
"number_of_replicas": 0,
"index.refresh_interval": 120,
"analysis": {
"analyzer": {
"autocomplete": {
"type": "custom",
@scottrice10
scottrice10 / elasticsearchIndexingNPIData.py
Created September 10, 2013 00:57
This simple script extracts json from npiapi.com’s json web service. Npiapi.com has a limit of 100 documents per request, and requests are divided into separate “offsets,” i.e. pages. So to document 74,000 documents, it is necessary to make 740 requests to the offsets 0-739. While this script is localized to a particular web service, the generic…
#!/usr/bin/env python
import requests
import json
data = []
limit = 100
offset = 740
chunks = 74
@scottrice10
scottrice10 / elasticsearchIndexing.py
Last active December 22, 2015 17:08
Indexing health provider data listed in NPI database using Elasticsearch.
#!/usr/bin/env python2.7
import csv
from pyes import *
reader = csv.reader(open('npidata_20050523-20130811.csv', 'rb'))
conn = ES('localhost:9200', timeout=20.0)
counter = 0
for row in reader: