This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # pushes the current branch to git hub and opens your browser to the | |
| # pull request page for the current branch | |
| OUTPUT=`(git push origin HEAD) 2>&1` | |
| URL=`echo $OUTPUT | sed -e 's/.*visiting: remote: \(https:\/\/github.com[A-Za-z0-9%\/_-]*\).*/\1/'` | |
| echo opening $URL | |
| open $URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Find jobs by class | |
| Sidekiq::Queue.new('queue').select{|j| j.display_class == 'Foo'} | |
| # Find jobs by argument (foo is the name of the argument and bar is the value in this case) | |
| Sidekiq::Queue.new('queue').select{|j| j['args'][0]['foo'] == 'bar'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'ruby-prof' | |
| RubyProf.start | |
| # code... | |
| result = RubyProf.stop | |
| printer = RubyProf::CallStackPrinter.new(result) | |
| printer.print(File.open('call_stack.html', 'w')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| header_string = File.open(file_path, 'r:bom|utf-8', &:readline) | |
| headers = CSV.parse(header_string).first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vim -c "set nobomb" -c wq! foo.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gzcat foo.gz | mysql -u root database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rsync -avzht -e ssh user@server:remote_path . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'csv' | |
| file = ARGV[0] | |
| rows = CSV.read(file, :encoding => 'windows-1251:utf-8') | |
| out = CSV.open("#{file.split('.')[0]}_fixed.csv", 'wb') | |
| rows.each{|row| out << row} | |
| out.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| times = [1,2,4,5,10,12,14,20,22,23,24] | |
| @group = 0 | |
| @delta = 3 | |
| def group(times) | |
| times.group_by do |item| | |
| index = times.index(item) | |
| if index <= times.size - 2 | |
| a = index + 1 |