Skip to content

Instantly share code, notes, and snippets.

View scottburton11's full-sized avatar

Scott Burton scottburton11

View GitHub Profile
@scottburton11
scottburton11 / gist:3239347
Created August 2, 2012 18:21
Warden FailureApp for Devise token_authentication
class MyApp::FailureApp < Devise::FailureApp
def respond
if api_token_failure?
invalid_token
elsif api_login_failure?
invalid_credentials
else
super
end
<html>
<head>
<script src="../javascripts/d3.v2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var g = d3.select("body").data([1,2,3,4]);
g.enter().append("p");
</script>
</head>
<body>
</body>
u = User.new(:name => "Borris Yeltzin", :date_of_birth => Date.today - 20.years, :ssn => "1234")
=> #<User id: nil, email: nil, name: "Borris Yeltzin", crypted_password: nil, salt: nil, claimable: true, date_of_birth: "1992-10-29", ssn: "1234", created_at: nil, updated_at: nil>
[4] pry(main)> u.save
(0.2ms) BEGIN
SQL (2.8ms) INSERT INTO "users" ("claimable", "created_at", "crypted_password", "date_of_birth", "email", "name", "salt", "ssn", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id" [["claimable", true], ["created_at", Mon, 29 Oct 2012 16:15:46 UTC +00:00], ["crypted_password", nil], ["date_of_birth", Thu, 29 Oct 1992], ["email", nil], ["name", "Borris Yeltzin"], ["salt", nil], ["ssn", "1234"], ["updated_at", Mon, 29 Oct 2012 16:15:46 UTC +00:00]]
(0.3ms) COMMIT
=> true
[5] pry(main)> u.update_attributes(:email => "borris.yeltzin@example.com", :password => "f00bar", :password_confirmation => "f00bar")
(0.2ms) BEGIN
(0.3ms) ROLLBACK
curl -X GET http://localhost:9200/gig_tracks/track/_search -d '
{ filter:
{ has_child:
{ type: gig_track,
filter:
{ geo_distance:
{ location :
{lat: 33, lng: -118},
distance: 100mi
}
@scottburton11
scottburton11 / Gemfile
Last active December 14, 2015 04:28 — forked from tsnow/README.md
source :rubygems
gem 'yajl-ruby'
@scottburton11
scottburton11 / gist:10221751
Created April 9, 2014 02:50
Facebook RSVP using the JS SDK
<html>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '721489701236648',
status : true,
xfbml : true
});
[
{"Year":"2018","Make":"Cadillac","Model":"CT6","Styling":"6","Acceleration":"4","Handling":"5","Fun Factor":"4","Cool Factor":"4","Weekend Score Total":"23","Features":"9","Comfort":"8","Quality":"8","Practicality":"5","Value":"7","Daily Score Total":"37","Total Score":"60","Video Link":"23:47","Filmed At City":"Tustin","Filmed At Country":"California","Vehicle Country":"USA","id":117},
{"Year":"2018","Make":"Bugatti","Model":"Chiron","Styling":"9","Acceleration":"10","Handling":"9","Fun Factor":"10","Cool Factor":"10","Weekend Score Total":"48","Features":"6","Comfort":"5","Quality":"7","Practicality":"1","Value":"6","Daily Score Total":"25","Total Score":"73","Video Link":"35:06","Filmed At City":"Toronto","Filmed At Country":"Ontario","Vehicle Country":"France","id":1},
{"Year":"2019","Make":"BMW","Model":"i8 Roadster","Styling":"7","Acceleration":"7","Handling":"7","Fun Factor":"6","Cool Factor":"7","Weekend Score Total":"34","Features":"7","Comfort":"6","Quality":"7","Practicality":"2","Value":"6
@scottburton11
scottburton11 / recover.rb
Last active January 11, 2023 23:22
Recover deleted S3 files from a versioned bucket
require 'json'
def recover_bucket(bucket)
list = `aws s3api list-object-versions --bucket #{bucket} --output json --query 'DeleteMarkers[?IsLatest==\`true\`].[Key, VersionId]'`
pairs = JSON.parse(list)
pairs.each do |(key, versionId)|
STDOUT.puts `aws s3api delete-object --bucket #{bucket} --key #{key} --version-id #{versionId}}`
end
end