Skip to content

Instantly share code, notes, and snippets.

View doyle's full-sized avatar

Christian Doyle doyle

View GitHub Profile
@doyle
doyle / docker_psql.sh
Created April 2, 2024 17:46
Dump and load a postgres database in a docker container
docker compose exec database pg_dump -U <user> -W <datbase> > database.sql
docker compose exec -T database psql -U <user> <database> < database.sql
@doyle
doyle / gist:92b0b34cd4804d237ed9661e20e33e5d
Created October 17, 2016 19:51
Use curl to upload a file to a S3 pre-signed url
curl -X PUT -T test_s3.txt -L "https://your-bucket.s3.amazonaws.com/url-stuff"
@doyle
doyle / remote.js
Created March 6, 2023 14:36
Simulates the remote: true behavior in rails's links
$('.some-class').on('click', function(e){
e.preventDefault();
$.getScript($(this).attr('href'));
});
@doyle
doyle / gh_stats.rb
Last active December 1, 2022 16:50
Pulls a list of an author's contributions to a GitHub organization
require 'octokit'
def gh_stats(org, author)
repos = repos(org, 'private')
repos += repos(org, 'public')
total_additions = 0
total_deletions = 0
total_commits = 0
@doyle
doyle / s3_sync.sh
Last active September 20, 2022 15:01
Example of copying files from s3 to local
aws s3 cp s3://path/to/bucket . --recursive
@doyle
doyle / install_xcode_command_line_tools.sh
Created June 9, 2022 13:53
Always run this after updating OSX
xcode-select --install
@doyle
doyle / rename_files_recursive.sh
Last active March 3, 2022 20:47
Recursively rename many files in a directory
find . -name *_foo.rb -exec rename 's/(.*)_foo.rb/\1_bar.rb/g' *.rb {} \;
# decrypts messages in the Futurama AL2 language: https://theinfosphere.org/Alien_languages
encrypted_message = %w(19 0 4 21 25 17 4 18 10 4 6 13 6 13 21 8 14 14 6 25 21 9).map(&:to_i)
decrypted_message = ''
encrypted_message.each_with_index do |value, index|
if index > 0
value = value - encrypted_message[index - 1]
value = value >= 0 ? value : 26 + value
end
@doyle
doyle / strftime_example.rb
Last active June 12, 2019 19:35
Shows common ways of formatting dates as strings
# 2019-10-14 14:32:55 -0400
Time.now.strftime('%Y-%m-%d %H:%M:%S %z')
# 2019-10-14 14:35:18.969 -0400
Time.now.strftime('%Y-%m-%d %H:%M:%S.%L %z')
@doyle
doyle / ruby_prof.rb
Last active May 17, 2019 19:29
ruby-prof example
require 'ruby-prof'
RubyProf.start
# code...
result = RubyProf.stop
printer = RubyProf::CallStackPrinter.new(result)
printer.print(File.open('call_stack.html', 'w'))