Skip to content

Instantly share code, notes, and snippets.

View skwp's full-sized avatar

Yan Pritzker skwp

View GitHub Profile
<script type='template/underscore' id='blog-inline-720-listings-template'>
<ul class='reverb-embedded-listings clearfix'>
<%_.each(listings, function (listing) { %>
<li class='reverb-embedded-listing reverb-embedded-listing-720'>
<a class='reverb-listing-embed' href='<%= listing._links.web.href %>'>
<img src='<%= listing.photos[0]._links.small_crop.href %>'></img>
<div class='reverb-embedded-listing-info'>
<span class='reverb-embedded-listing-title'><%= listing.title %></span>
<span class='reverb-embedded-listing-price'><%= listing.price.symbol %><%= listing.price.amount %></span>
</div>
module RateLimitedWorker
def self.included(clazz)
# Shopify allows us to do 2r/sec/shop burstable to 40/s
#
# In order to say within limits, we're going to do 5 every 2 seconds
# which works out to 2.5/s. If this sustains for too long, we'll probably
# bleed out of their rate limit bucket but then the sleeps defined in
# ActiveResoruce::Connection (initializers/sidekiq_rate_limiting) will kick in
#
# Usage:
# To log in:
curl -XPOST --data "email=your@email.com&password=foo" https://reverb.com/api/auth/email
# To sign up:
curl -XPOST --data "email=your@email.com&password=foo&first_name=Joe&last_name=Schmoe" https://reverb.com/api/accounts
# To login or sign up with facebook:
curl -XPOST --data "fb_token=facebook_oauth_token" https://reverb.com/api/auth/facebook.
# Using form body
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" --data 'email=foo@bar.com&password=asdf' https://reverb.com/api/auth/email.json
# Using HAL/JSON
curl -X POST -H "Content-Type: application/hal+json" --data '{"email": "foo@bar.com", "password": "asdf"}' https://reverb.com/api/auth/email.json
{"listings":[{
"id":3548,
"make":"BOSS",
"model":"OC-2 Octave Pedal",
"finish":"",
"year":"",
"title":"BOSS OC-2 Octave Pedal",
"created_at":"2013-02-26T17:59:45-06:00",
"_links":{
"self":{"href":"/listings/3548"},
{
"_links": {
"next":{"href":"/listings/?page=2"},
"prev": {"href":"/listings/?page=1"}
},
"listings":[
{
"some": "data"
}
]
curl -XPOST "https://reverb.com/api/listings -H "X-Auth-Token: [yourtoken]"
{
"make": "Fender",
"model": "Stratocaster",
"product_type": "electric-guitars",
"condition": "Brand New",
"photos": [
"http://i.stack.imgur.com/Sv4BC.png"
],
"description": "Awesome guitar",
{
"message": "This is the human readable summary of problems",
"errors": {
"password": [
"is too short (minimum is 5 characters)"
]
}
}
@skwp
skwp / webhooks.sh
Created March 17, 2015 17:34
Reverb Webhooks
# Creating a webhook registration
curl -XPOST https://reverb.com/api/webhooks/registrations --data '{"url": "http://requestb.in/yourendpoint", "topic": "listings/update"}' -H "X-Auth-Token: [yourtoken]" -H "Content-Type: application/hal+json" -H "Accept: application/hal+json"
# Getting a list of webhooks
curl -XGET https://reverb.com/api/webhooks/registrations -H "X-Auth-Token: [yourtoken]" -H "Content-Type: application/hal+json" -H "Accept: application/hal+json"
# Deleting a webhook (following the _links.self.href link that comes back on the webhook list
curl -XDELETE https://reverb.com/api/webhooks/registrations/[webhook_id] -H "X-Auth-Token: [yourtoken]" -H "Content-Type: application/hal+json" -H "Accept: application/hal+json"
@skwp
skwp / reverb_search_bar.html
Last active August 29, 2015 14:20
Reverb Search Bar
<!--
Example: search all listings
-->
<form action="https://reverb.com">
<input type="hidden" name="_aid" value="[your affiliate id]">
<input name="query" style="font-size: 1.10em; border: 1px solid #d2d2d2; background-color: #f2f2f0; padding: 0.42857rem 0.85714rem; -webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px; width: 400px;" placeholder="Find Gear on Reverb">
<input type="image" alt="Submit Search" src="http://i.imgur.com/Xqd1zPL.png?1" style="height: 32px; margin-bottom: -10px">
</form>