Skip to content

Instantly share code, notes, and snippets.

View ryannealmes's full-sized avatar

Ryan-Neal Mes ryannealmes

View GitHub Profile
@ryannealmes
ryannealmes / gist:3187eb7f94eb5fca0a2d
Created November 10, 2014 15:09
Adding terminal short cuts for applications

Create a sym link between the application and a folder.

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

Make sure that folder is included in your .bash_profile export PATH

@ryannealmes
ryannealmes / gist:9c148a6c4b35aefaf505
Last active July 5, 2017 23:08
How to managed services and dependencies ...
# adapted from
# http://adamniedzielski.github.io/blog/2014/11/25/my-take-on-services-in-rails/
class CreateUserAccount
attr_reader :user
def initialize(send_email_service: SendEmail.new, generate_token_service: GenerateToken.new)
@send_email_service = send_email_service
@generate_token_service = generate_token_service
end
@ryannealmes
ryannealmes / gist:062283cf66b126f8eb85
Created December 19, 2014 13:23
Check for apache config errors
sudo apachectl -t
@ryannealmes
ryannealmes / gist:71508afec9fc54c9c1f2
Last active August 29, 2015 14:17
Database/Table size in MB
You can use this query to show the size of a table:
SELECT table_name AS "Table",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "$DB_NAME"
AND table_name = "$TABLE_NAME";
or this query to list the size of every table in the database, largest first:
SELECT table_name AS "Tables",
@ryannealmes
ryannealmes / gist:2698f14e406b279056e8
Created May 11, 2015 08:55
Alter collation of table
ALTER TABLE mytable CONVERT TO CHARACTER SET utf8 collate utf8_unicode_ci;

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@ryannealmes
ryannealmes / gist:4f6b5da6e327de2184bc
Last active August 29, 2015 14:23
grep large files
B = before
A = after
grep -B [number of lines] -A [number of lines] [search string] [file]
If you want the same number of lines before and after you can use -C num.
grep -C [number of lines] [search string] [file]
@ryannealmes
ryannealmes / gist:aa4eed8b222239c9e207
Created August 27, 2015 13:52
Update Git submodule to latest commit on origin
# get the submodule initially
git submodule add ssh://bla submodule_dir
git submodule init
# time passes, submodule upstream is updated
# and you now want to update
# change to the submodule directory
cd submodule_dir
@ryannealmes
ryannealmes / gist:353dcc7f185729c2958d
Created September 10, 2015 08:43
How to kill all processes with a given name
kill $(ps aux | grep '[d]elayed_job' | awk '{print $2}')
Credit:
http://stackoverflow.com/questions/3510673/find-and-kill-a-process-in-one-line-using-bash-and-regex
@ryannealmes
ryannealmes / gist:93085f2e5fbf41cd157c
Created September 30, 2015 10:57
Get directory file sizes
$ du -sh /path/to/dir/*/
48K /path/to/dir/dir1/
4.0K /path/to/dir/dir2/
6.7M /path/to/dir/dir3/
20K /path/to/dir/dir4/
8.0K /path/to/dir/dir5/
44K /path/to/dir/dir6/
Credit to http://superuser.com/questions/171534/list-the-current-folder-folders-sizes-with-the-terminal/171553#171553?newreg=0e154f897f58423793e8e11fe72e4c1f