This file contains 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
h=fs.open("/gfs","w");h.write(http.get("https://gist.github.com/ntalbott/4719172/raw/gfs.lua").readAll());h.close();print "Done"; |
This file contains 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
# Helper class to save urls to a file | |
class UrlLoader | |
# Download a url and optionally specify a path to save it to a file. | |
def self.get(url, path=nil) | |
# set curl to timeout after 30 minutes for any calls | |
cmd = "curl --fail --location --silent --show-error --max-redirs 10 --connect-timeout 60 --max-time 1800" | |
cmd += " --output #{path}" unless path.nil? | |
cmd += " '#{url}'" | |
rsp = `#{cmd}` | |
raise "Received non-success response code for url: '#{url}'" if (path.nil? ? rsp.empty? : (!File.exists?(path) || File.size(path) == 0)) |
This file contains 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
# NOTE: To test asset pipeline in development set the following config.assets.* below in | |
# your config/environments/development.rb and then run: | |
# | |
# $ RAILS_ENV=development rake assets:precompile | |
# | |
# It is recommended you rm -rf public/assets and turn off these settings in development when | |
# you are finished or this may cause issues with assets in your local development environment | |
# | |
# config.assets.compress = true | |
# config.assets.compile = false |
This file contains 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
<style> | |
#notification-box { | |
position: absolute; | |
top: 25px; left: 0; | |
width: 100%; | |
padding: 0; margin: 0; | |
} | |
</style> | |
<div id="notification-box"> |
This file contains 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
# contains common attachment methods | |
# NOTE: this currently assumes the attachment is called 'attachment' | |
module Attachable | |
# determines if an attachment may have a thumbnail | |
def thumbnailable? | |
!(attachment_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png|pdf)$}).nil? | |
end | |
def image_dimensions(max=400) |
This file contains 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
var App = App || {}; | |
App.Commentable = function(options) { | |
var options = $.extend({ | |
log_tail: 'is the greatest' | |
}, options); | |
return { | |
log: function(msg) { | |
console.log(msg + ' ' + options.log_tail); | |
} |
This file contains 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
// Setup an App namespace for all other Javascript to hook to. | |
var App = {}; | |
// Watch is a utility for hooking into form changes | |
// | |
// Example: | |
// App.Watch.init("#company-filter", function(el){}); | |
App.Watch = (function() { | |
function init(el, handler) { | |
$(el).on("propertychange keyup input paste", function() { |
This file contains 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
> response.headers["HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT"] | |
"1/40" |
This file contains 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
# use a shared lock and credits_remaining | |
@lock = Mutex.new | |
@credits_remaining = 40 | |
@shopify_url = ENV["SHOPIFY_URL"] | |
# Sends a request to Shopify, blocking until credits are available | |
def self.request(method, path, params={}) | |
params[:headers] = {"Content-Type" => "application/json"} | |
# wait for a credit |
This file contains 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
# Run 42 threads to hit the call limit | |
42.times.each do | |
Thread.new { Shopify.get_product(1234567890) } | |
end |
OlderNewer