Skip to content

Instantly share code, notes, and snippets.

View kany's full-sized avatar

Frank Kany kany

  • Rickman, TN
View GitHub Profile
@kany
kany / yaml output rails console
Created December 13, 2012 19:26
Yaml Output in Rails Console
1) rails c
2) YAML::ENGINE.yamler = 'syck'
3) y @user.participant
--- !ruby/object:Participant
attributes:
id: 9
employee_hashed_ssn: "hashed ssn: 00001"
ch_member_id: 100
first_name: Test Employee 00001
@kany
kany / airbrake.rb
Created October 26, 2015 19:43
Test Airbrake From Rails Development Environment
# Add 'config.development_environments = []' to config/initializers/airbrake.rb
Airbrake.configure do |config|
config.api_key = "1234"
config.environment_name = AppConfig.environment if AppConfig.environment
config.secure = true
config.development_environments = []
end
# Test it out in the console
1) rails console
@kany
kany / Taming Git
Last active December 10, 2015 23:39
Taming Git
Taming GIT
Using Git - and Git Flow
First up: Git for Agile Teams (pdf) should be considered required reading :)
Second, keep this diagram in mind while reading the following text (image source)
Git Flow
There is nothing special about Git Flow - everything is still commits, branches and tags, but the toolset does add some convenient shortcuts for common operations. Examples include making a hotfix for the current production version, and keeping track of multiple features under concurrent development. Git Flow does nothing special to commits, nor are the branches any different from branches you create by other means. A strict naming standard does make things easier to follow, though.
@kany
kany / Search Git Logs
Last active December 10, 2015 23:49
Search Git Logs
Search git logs for tickets = 5803,5804,or5805 using regex.
http://gitready.com/advanced/2009/01/20/bend-logs-to-your-will.html
git log --grep=580[345] --stat -p --author=frank
@kany
kany / Reset MySQL 'root' user password
Last active December 11, 2015 20:58
Reset MySQL 'root' user password
This method only works if currently logged in as root. Sometimes when working with older ruby 'mysql' gems, after the 'mysql' gem is installed, the previous password doesn't work.
1) Already logged into Mysql
2) gem jacked up your mysql password
3) mysql > use mysql;
4) mysql > UPDATE user SET Password=PASSWORD('') WHERE User='root'; FLUSH PRIVILEGES;
@kany
kany / Look for items hogging disk space on Mac
Last active December 11, 2015 20:59
Look for items hogging disk space on Mac
Change to root directory
1) cd /
See size of each file/folder in directory with sorting
2) sudo du -sh * | sort -gr
If /SomeFolder is over 1gb
3) cd SomeFolder && sudo du -sh *
@kany
kany / foreign_keys
Created March 4, 2013 18:51
Find Foreign Keys - Mysql
select
concat(table_name, '.', column_name) as 'foreign key',
concat(referenced_table_name, '.', referenced_column_name) as 'references'
from
information_schema.key_column_usage
where
referenced_table_name is not null AND
referenced_table_name = 'org_units';
mkdir -p ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/CoffeeScript
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/CoffeeScript
curl -O https://raw.github.com/jashkenas/coffee-script-tmbundle/master/Syntaxes/CoffeeScript.tmLanguage
curl -O https://raw.github.com/jashkenas/coffee-script-tmbundle/master/Preferences/CoffeeScript.tmPreferences
@kany
kany / resque.rake
Created September 11, 2013 18:14 — forked from denmarkin/resque.rake
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@kany
kany / raw_sql_to_calculate_distance.rb
Last active September 26, 2016 16:10
Use raw sql to calculate distance between latitude/longitude coordinates
# Use raw sql to calculate distance between latitude/longitude coordinates
# From the web
# - http://gis.stackexchange.com/questions/31628/find-points-within-a-distance-using-mysql
"SELECT
id, (
3959 * acos (
cos ( radians(78.3232) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(65.3234) )