Skip to content

Instantly share code, notes, and snippets.

@austra
austra / gist:53721da86b149718160b
Created October 26, 2015 21:01 — forked from deevis/gist:359741f1e498da14f9e3
Choose multiple files from current branch as the 'merge conflict winner'
# 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
@austra
austra / gist:d8f5a1de00f12c253716
Last active July 12, 2020 21:33
Pagination Headers With Kaminari for API
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
rsync -avzP -e "ssh -i /home/user/my.pem" [email protected]:/home/ubuntu/remote-dir /home/user/local-dir
@austra
austra / gist:895d0fc7f450658fc564
Created April 9, 2015 23:08
git log searching
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)
@austra
austra / gist:4a299cd9dd94794a36e0
Created April 2, 2015 01:28
redis expiration listener
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
@austra
austra / gist:51191fe7fd043ae31ae8
Created March 9, 2015 16:33
rails jquery unobtrusive onclick
Obtrusive:
link_to 'Another link with obtrusive JavaScript', '#',
:onclick => 'alert("Please no!")'
Unobtrusive:
rails:
link_to 'Link with unobtrusive JavaScript',
@austra
austra / gist:868e06718c00ffee70d2
Created February 11, 2015 20:10
confimation before ajax request
$('.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...