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
tracks_with_date = [ | |
["6GZeeRql1kto2a7koIve9i", "2018-11-13 05:02:50 UTC"], | |
["6pXJV9kSdjyAcDsM32ftLK", "2018-11-13 05:02:50 UTC"], | |
["5x9jMerOQr7oTF1GO4STRY", "2018-11-13 05:02:50 UTC"], | |
["2hLTFcVb0k2xpHXZblhu7Y", "2018-11-13 05:02:50 UTC"], | |
["77L5jfCpmpkDma5lXjG6oX", "2018-11-13 05:02:50 UTC"], | |
["6rux2bYOCSr2woxnQsoUE3", "2018-11-13 05:02:50 UTC"], | |
["0gjknY5vRTKbzMos2hhfN7", "2018-11-13 05:02:50 UTC"], | |
["0ZHn1GiKfyLgpvEks2wBcn", "2018-11-13 05:02:50 UTC"], | |
["25EmPX0QaVUOzi2sG3fZEp", "2018-11-13 05:02:50 UTC"], |
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
# config/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
end |
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
# http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
# http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
# payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
# data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
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
def compare_to(version) | |
reject_fields = ["_id", "updated_at", "version"] | |
diff_array = self.versions[version-1].attributes.to_hash.to_a - self.attributes.to_hash.to_a | |
diff_array.delete_if {|f| reject_fields.include?(f.first) } | |
Hash[diff_array] | |
end |
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
// Provides a device_scale class on iOS devices for scaling user | |
// interface elements relative to the current zoom factor. | |
// | |
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari | |
// Copyright (c) 2010 37signals. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
# Monitor HTTP requests being made from your machine with a one-liner.. | |
# Replace "en1" below with your network interface's name (usually en0 or en1) | |
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" | |
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile: | |
# (again replace "en1" with correct network interface name) | |
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"" | |
# All the above tested only on OS X. |