This file contains 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
$('.removeItem').click(function (event) { | |
if (confirm('Are you sure you want to delete this?')) { | |
$.ajax({ | |
url: 'myUrl', | |
type: "POST", | |
data: { | |
// data stuff here | |
}, | |
success: function () { | |
// does some stuff here... |
This file contains 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
Obtrusive: | |
link_to 'Another link with obtrusive JavaScript', '#', | |
:onclick => 'alert("Please no!")' | |
Unobtrusive: | |
rails: | |
link_to 'Link with unobtrusive JavaScript', |
This file contains 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
def start_listener() | |
uri = URI.parse(ENV["REDISCLOUD_URL"]) | |
redis = Redis.new(host: uri.host, port: uri.port, password: uri.password) | |
Thread.new do | |
begin | |
redis.subscribe("__keyevent@0__:expired") do |on| | |
on.subscribe do |channel, subscriptions| | |
puts "Subscribed to ##{channel} (#{subscriptions} subscriptions)" | |
end |
This file contains 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
To search the commit log (across all branches) for the given text: | |
git log --all --grep='my commit message' | |
To search the actual content of commits through a repo's history, use: | |
git grep 'my commit message' $(git rev-list --all) |
This file contains 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 -avzP -e "ssh -i /home/user/my.pem" [email protected]:/home/ubuntu/remote-dir /home/user/local-dir |
This file contains 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
http://jaketrent.com/post/pagination-headers-with-kaminari/ | |
https://developer.github.com/v3/#pagination | |
Kaminari provides easy pagination in a rails app. It’s great to use. We’ll make it better by adding a little function to your controllers to provide useful pagination headers. | |
kaminari pagination | |
Pagination from Kaminari |
This file contains 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
# All the files that match with 'coverage' and tell git to use the branch we're on currenthl (ours, opposed to theirs) | |
git status | grep coverage | sed 's/.*: \(.*\)/\1/g' | xargs git checkout --ours |
This file contains 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
zgrep "END: current_user" production.log.2.gz | sed 's/\(.*\) \[.*INFO.*current_user\[\(.*\)\] (\(.*\)) \(.*\)/\3\t\4\t\2\t\1/g' | sort -n | tail -n 20 | |
# with process:request | |
grep "END: current_user" production.log | sed 's/\(.*\) \[.*INFO.*\[\(.*\)\].*current_user\[\(.*\)\] (\(.*\)) \(.*\)/\4\t\2\t\1\t\3\t\5/g' | sort -n | tail -n 100 | |
# find with process:request, then loop back and find problems for each... | |
# Part 1 | |
grep "END: current_user" production.log | sed 's/\(.*\) \[.*INFO.*\[\(.*\)\].*current_user\[\(.*\)\] (\(.*\)) \(.*\)/\4\t\2\t\1\t\3\t\5/g' | sort -n | tail -n 100 > slow_requests_10_26_2015.txt | |
# Part 2 | |
for rqid in `cat slow_requests_10_26_2015.txt | sed 's/.*seconds\t\(.*\)\s.*2015.*/\1/g'`;do echo -e "API Calls for [$rqid]\n---------------------------\n"; grep $rqid production.log | grep "request to api.exigo.com" -A 1; echo -e "\n\n";done > exigo_slow_calls_report_10_26_2015.txt |
This file contains 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
for request in `grep -e "undefined local variable or method .*html_safe" log/production.log -B 1 | grep FATAL | sed 's/.*FATAL.*\[\(.*\)\]/\1/g'`;do grep "$request" log/production.log | head -n 20 | grep current_user;done | sed 's/.*current_user\(.*\).*/\1/g' | sort | uniq -c | sort -n |
This file contains 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
raw = ActiveRecord::Base.connection.execute(sql) | |
raw.each(:as => :hash) do |row| | |
puts row.inspect # row is hash | |
end |
OlderNewer