Skip to content

Instantly share code, notes, and snippets.

View tkling's full-sized avatar
🍕

Tyler Kling tkling

🍕
View GitHub Profile

##Reasons to want OpsWorks

  1. can finally do machine config without adding things (.ebextensions) to our app
  2. config recipes can finally be SHARED! no more duplicate scripts in consumer-domain and cb-mobile
  3. scheduled instances
  • no more latency/noise at ~8am when we wake up 10 extra boxes
  1. chef support is pretty sweet
  • chef 11.10 - nice and recent, and gets updates!
  • berkshelf built in - it's like Bundler for chef cookbooks
    • so many good public cookbooks to take advantage of!
  • now that it works we could save some time with this

Redis as an OSX service!

####here's where this solution was pulled from: Ted Naleid's blog

####minor changes in this gist:

  • service name => calling io.redis.redis-server seemed like too much, redis is easier to remember
  • using nano instead of vim in steps since working with vim is awkward if you don't do it often
@tkling
tkling / memory_plan.txt
Last active June 30, 2016 17:14
Memory leak plan
memory plan:
============
- SSH to server
- add rbtrace (require: false) to gemfile, bundle install
- change passenger to only run 1 instance (via json config file)
- add this to before filter in applicaton_controller.rb:
require 'rbtrace'
- add this to application.rb:
require 'objspace'
@tkling
tkling / rack-timeout-seems-ok.rb
Last active June 14, 2017 18:34
rack-timeout will raise errors during HTTP waits
# in Gemfile
gem 'rack-timeout', '~> 0.4'
# add a throwaway controller for testing
class WaitController < ApplicationController
def index
sleep 20
render plain: 'lol we waited 20 seconds'
end
// mostly pulled from http://www.4tronix.co.uk/arduino/Stepper-Motors.php lol
int motorPin1 = 8; // Blue - 28BYJ48 pin 1
int motorPin2 = 9; // Pink - 28BYJ48 pin 2
int motorPin3 = 10; // Yellow - 28BYJ48 pin 3
int motorPin4 = 11; // Orange - 28BYJ48 pin 4
int motorSpeed = 1200; // stepper speed
int countsperrev = 512; // number of steps per full revolution
int revs_per_door_action = 0; // need to figure this out!
@tkling
tkling / dnd-companion-notes.md
Last active May 27, 2020 14:50
dnd-companion notes
  1. using class level state is generally considered to be dangerous. (@@var type stuff) - OK for this project since it's the only thing using its own code, but if this were a gem where people could pull in your code, imagine what would happen if someone accesses the Conditions/Equipments/Spells @@all attribute and changes stuff?
  • as an alternative, you could create wrapping objects (something like EquipmentCollection) that exist just to fetch and hold all of the items, and your CLI would talk to those Collection objects to present the lists of all of the items.
  1. consider using a gemfile/gemspec (gemspec if this could be a gem) to declare your dependencies
  2. declaring an array and shoveling items into it is redundant in ruby:
    things = []
    doodads.each { |dd| things << "based god say: #{dd}" }
    
    # is equivalent to:
@tkling
tkling / crdb_transaction_retry.rb
Last active March 20, 2023 18:18
CockroachDB TransactionManagerMonkeyPatch monkey patch :D
# this lives in config/initializers
require 'active_record/connection_adapters/cockroachdb/transaction_manager'
require 'pg'
module ActiveRecord
module ConnectionAdapters
module CockroachDB
module TransactionManagerMonkeyPatch
alias_method :old_retryable?, :retryable?
@tkling
tkling / crdb_index_hint_extensions.rb
Created March 30, 2023 15:03
ActiveRecord::Relation methods for fluent force-index and index-hint query modifications with CockroachDB-specific syntax
module ActiveRecord
class Relation
def force_index(index_name, direction: nil)
directionality = direction.to_s.upcase
directionality = directionality.in?(%w[ASC DESC]) ? ",#{directionality}" : ""
@crdb_force_index = "FORCE_INDEX=#{index_name}#{directionality}"
compiled_index_hint_text
end