Skip to content

Instantly share code, notes, and snippets.

View maxehmookau's full-sized avatar

Max Woolf maxehmookau

View GitHub Profile
upstream myhealthcare {
server 192.168.12.10:9292;
}
server {
listen 80;
try_files $uri @app;
location @app {
@maxehmookau
maxehmookau / main.go
Created October 11, 2016 14:25
Little teabot. My first go.
package main
import (
"fmt"
"os"
)
func main() {
args := os.Args[1:]
name := args[0]
require "benchmark"
Benchmark.bmbm do |x|
x.report("min") { (1..10000000).to_a.shuffle.min }
x.report("max") { (1..10000000).to_a.shuffle.max }
end
# Ruby 2.4-rc
user system total real
min 0.750000 0.000000 0.750000 ( 0.756316)
max 0.770000 0.020000 0.790000 ( 0.794998)
@maxehmookau
maxehmookau / docker-compose.yml
Created January 5, 2017 09:36
Simple Moodle 3.2 Installation on Docker Compose
version: '2'
services:
moodle:
image: jhardison/moodle
links:
- moodle_db
environment:
MOODLE_URL: "http://0.0.0.0:8080"
DB_PORT_3306_TCP_ADDR: moodle_db
DB_ENV_MYSQL_USER: moodle
@maxehmookau
maxehmookau / from_this.rb
Created January 9, 2017 11:18
Refactoring using Sandi Metz 99 bottles examples for Rails helper
module PlaylistCommentsHelper
def pinning_link(comment)
if comment.pinned?
unpin_link(comment)
else
pin_link(comment)
end
end
def unpin_link(comment)
00:00 git:wrapper
00:00 git:check
00:00 deploy:check:directories
00:00 deploy:check:linked_dirs
00:00 sidekiq:quiet
00:00 git:clone
00:00 git:update
00:00 git:create_release
00:00 deploy:set_current_revision
00:00 deploy:symlink:linked_dirs
lock '3.7.2'
set :application, 'my application'
set :repo_url, 'somethingsomething.git'
set :ssh_options, proxy: Net::SSH::Proxy::Command.new("ssh -W %h:%p -q root@proxy_server} -i {private_key_for_proxy} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no")
# All your other configs...
# Note: -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
# This can be potentially unsafe on an unknown network but is helpful for
@maxehmookau
maxehmookau / test_results_controller.rb
Created July 11, 2017 15:07
Standard Controller Example
class TestResultsController < ApplicationController
def index
@test_results = current_user.test_results
end
end
@maxehmookau
maxehmookau / user.rb
Created July 11, 2017 15:10
Slow user model
class User < ApplicationRecord
# ...
def test_results
# This API endpoint is slow.
HTTParty.get('https://someapi.com/test_results/user_id')
end
end
@maxehmookau
maxehmookau / background.log
Last active July 11, 2017 15:22
Preloading patient details
web_1 | I, [2017-07-11T14:01:06.771698 #11] INFO -- : Enqueued PreloadPatientRecordsJob (Job ID: ba184519-ccdb-4486-8c58-2cbe53b5abec) to Sidekiq(default) with arguments: #<GlobalID:0x007efe11a29890 @uri=#<URI::GID gid://myhealthcare/User/1>>
sidekiq_1 | 2017-07-11T14:01:08.087Z 1 TID-gs5hwxk04 PreloadPatientRecordsJob JID-d4d16a61150c753aed7c75be INFO: start
sidekiq_1 | D, [2017-07-11T14:01:10.062434 #1] DEBUG -- : Setting cache key: details.
sidekiq_1 | D, [2017-07-11T14:01:10.082970 #1] DEBUG -- : Setting cache key: observations.
sidekiq_1 | D, [2017-07-11T14:01:10.149937 #1] DEBUG -- : Setting cache key: conditions.
sidekiq_1 | D, [2017-07-11T14:01:10.172276 #1] DEBUG -- : Setting cache key: allergies.
sidekiq_1 | D, [2017-07-11T14:01:10.194290 #1] DEBUG -- : Setting cache key: immunizations.
sidekiq_1 | D, [2017-07-11T14:01:10.214040 #1] DEBUG -- : Setting cache key: all_medications.
sidekiq_1 | D, [2017-07-11T14:01:10.252209 #1] DEBUG -- : Setting cache