Skip to content

Instantly share code, notes, and snippets.

@atomgiant
atomgiant / bootstrap.lua
Last active March 20, 2021 01:47
MineCraft Lua scripts
h=fs.open("/gfs","w");h.write(http.get("https://gist.github.com/ntalbott/4719172/raw/gfs.lua").readAll());h.close();print "Done";
@atomgiant
atomgiant / url_loader.rb
Created March 17, 2013 13:14
Curl url downloader as an alternative to curb
# 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))
@atomgiant
atomgiant / gist:5438672
Last active December 16, 2015 12:59
How To Test Rails Asset pipeline in development
# 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
@atomgiant
atomgiant / gist:6270147
Created August 19, 2013 15:03
Notification box css for full width
<style>
#notification-box {
position: absolute;
top: 25px; left: 0;
width: 100%;
padding: 0; margin: 0;
}
</style>
<div id="notification-box">
@atomgiant
atomgiant / paperclip
Created August 27, 2013 19:58
Paperclip attachment settings for width / height and thumbnail determination
# 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)
@atomgiant
atomgiant / gist:8247276
Last active January 2, 2016 03:59
JS Module
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);
}
// 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() {
> response.headers["HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT"]
"1/40"
# 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
# Run 42 threads to hit the call limit
42.times.each do
Thread.new { Shopify.get_product(1234567890) }
end