Skip to content

Instantly share code, notes, and snippets.

View rossta's full-sized avatar
💭
Being curious

Ross Kaffenberger rossta

💭
Being curious
View GitHub Profile
@rossta
rossta / find_and_replace.sh
Created February 4, 2014 22:42
Find and replace in directory on the shell
# example: replacing :mocha with :rspec as mock framework
find . -name '*_spec.rb' -exec sed -i.old -e 's/returns/and_return/' {} \;
find . -name '*_spec.rb' -exec sed -i.old -e 's/expects/should_receive/' {} \;
find . -name '*_spec.rb' -exec sed -i.old -e 's/stubs/stub/' {} \;
find . -name '*.old' -exec rm {} \;
@rossta
rossta / flag_datafix.rb
Last active August 29, 2015 13:57
Notes for orphaned flag datafix
# flags orphaned from forum topics (discussions)
Flag.joins("LEFT OUTER JOIN forum_topics ON flags.flaggable_id = forum_topics.id").where('forum_topics.id IS NULL').where(flaggable_type: 'ForumTopic')
# flags orphaned from comments
Flag.joins("LEFT OUTER JOIN comments ON flags.flaggable_id = comments.id").where('comments.id IS NULL').where(flaggable_type: 'Comment')
@rossta
rossta / transliteration.yml
Created May 5, 2014 17:31
Default I18n transliteration converted to YAML
# I18n::Backend::Transliterator::HashTransliterator::DEFAULT_APPROXIMATIONS.to_yaml
---
À: A
Á: A
Â: A
Ã: A
Ä: A
Å: A
Æ: AE
Ç: C
@rossta
rossta / nginx_functions.zsh
Created June 3, 2014 20:10
nginx functions
lsnginx() {
ps -A -o pid,command | grep '[n]ginx'
}
startnginx() {
sudo nginx -c /web/platform/config/nginx/nginx.conf
}
startnginxssl() {
sudo nginx -c /web/platform/config/nginx/nginx.ssl.conf
@rossta
rossta / sunspot.yml
Created June 6, 2014 14:57
Updated sunspot yml
test:
solr:
hostname: localhost
port: 9008
log_level: WARNING
solr_home: solr
development:
solr:
hostname: localhost
@rossta
rossta / query.sql
Created March 13, 2015 20:47
Find largest tables on MYSQL server
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
@rossta
rossta / configure_nginx_rails.rb
Last active August 29, 2015 14:17
Configure nginx for rails
#!/usr/bin/env ruby
require 'erb'
puts "Generating nginx config..."
app_root = Dir.getwd
app_name = File.basename(app_root)
public_path = File.join(app_root, 'public')
@rossta
rossta / install.txt
Created April 9, 2015 03:22
ember-cli@0.2.3 install output
$ npm install --save-dev ember-cli@0.2.3
> ws@0.5.0 install /Users/ross/dev/challengepost/bridge/node_modules/ember-cli/node_modules/testem/node_modules/socket.io/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
@rossta
rossta / railsconf-notes.md
Last active August 29, 2015 14:20
railsconf 2015 notes

RailsConf Show & Tell

Keynotes

  • Kent Beck: "A man cannot be comfortable without his own approval" - Mark Twain *
  • DHH @ 00:26:00: Rails API and Action Cable
  • Tenderlove: Just watch

Culture

@rossta
rossta / opsworks-intro.md
Last active August 29, 2015 14:20
Introduction to AWS OpsWorks

Intro to AWS OpsWorks for the Rails Developer

AWS OpsWorks

AWS OpsWorks features an integrated management experience for the entire application lifecycle including resource provisioning, configuration management, application deployment, monitoring, and access control. It will work with applications of any level of complexity and is independent of any particular architectural pattern.

Wat?

  • Configure instances
  • Automate provisioning