Skip to content

Instantly share code, notes, and snippets.

View JonCrawford's full-sized avatar
🏗️
Helping startups on product, tech & data analytics

Jonathan Crawford JonCrawford

🏗️
Helping startups on product, tech & data analytics
View GitHub Profile
@JonCrawford
JonCrawford / store.rb
Created April 17, 2012 23:09
Use after_commit instead of after_create for Resque jobs.
# Redis is faster than Mysql so it may cause a RecordNotFound to happen if enqueued from after_create
before_create :set_recently_opened
after_commit :if => :recently_opened? do |record|
Resque.enqueue StoreAfterCreate, record.id
UserMailer.store_signup(record.owner_user_id, record.id).deliver
end
def set_recently_opened
@recently_opened = true
end
@JonCrawford
JonCrawford / collection.liquid
Created July 14, 2012 23:52
Adding on sale, preorder, sold out, and coming soon to your product page
...
<li class="product" id="products_{{product.id}}">
<a href="{{product.url}}">
<span class="{{ product.css_class }}">
{% if product.on_sale %}
<img src="/themes/default/images/label-onsale.png" width="98" height="98" alt="On Sale" />
{% endif %}
{% if product.preorder %}
<img src="/themes/default/images/label-preorder.png" width="98" height="98" alt="Pre-Order" />
{% endif %}
@JonCrawford
JonCrawford / sql_queries.sql
Created October 30, 2014 00:13
Vanity ID SNAFU Recovery
SELECT orders.id, orders.vanity_id, orders.payment_state, orders.confirmed_at, orders.store_id, store_subdomain from orders WHERE orders.vanity_id < 100000 and orders.confirmed_at > DATE_SUB(NOW(), INTERVAL 5 DAY) AND orders.store_id IN (528222, 18784) order by vanity_id, store_id;
@JonCrawford
JonCrawford / clean_resque_worker_keys.rb
Created October 13, 2015 14:43
Clean Stale Resque Workers
Resque.working.select{|w| DateTime.parse(w.job["run_at"]) < 5.hours.ago }.map do |worker|
worker.shutdown
worker.unregister_worker
end
Verifying my Blockstack ID is secured with the address 1DcoBDY6S7QELM7qvmgqibASxd3jP2L2kB https://explorer.blockstack.org/address/1DcoBDY6S7QELM7qvmgqibASxd3jP2L2kB