Skip to content

Instantly share code, notes, and snippets.

Stefan Wrobel swrobel

Block or report user

Report or block swrobel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@swrobel
swrobel / bench.rb
Created Aug 3, 2019
Ruby memoization gem benchmarks
View bench.rb
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem 'benchmark-ips'
gem 'benchmark-memory'
gem 'memo-it'
gem 'memoist'
gem 'memery'
View gist:77626ff3d4967ca65c3028dcb336d57a

UTC -11:00

  • American Samoa
  • International Date Line West
  • Midway Island

UTC -10:00

  • Hawaii

UTC -09:00

@swrobel
swrobel / dedup-imovie-library
Last active Sep 30, 2017 — forked from kabadisha/dedup-imovie-library
When you import movies into iMovie 10 libraries, the file is always copied, wasting space and hindering editability. This script replaces the copy with a hardlink, reclaiming disk space.
View dedup-imovie-library
#!/usr/bin/env ruby
# Usage: dedup-imovie-library LIBRARY ORIGINALS
#
# Goes through an iMovie 10 library and replaces all the "Original Media" with
# symlinks to the actual original media, in order to conserve disk space. Note
# that because they're symlinks, if the path to the originals changes (e.g. you
# rename the external drive they are on) then the links will be broken.
#
# This assumes you've already imported the files into iMovie and waited for them
@swrobel
swrobel / range_within_bounds.rb
Created Apr 7, 2016
Return a range that is bounded by min & max given, in Ruby
View range_within_bounds.rb
def range_within_bounds(range, min, max)
min ||= range.min
max ||= range.max
[range.min, min].max .. [range.max, max].min
end
View default_scope_failing_tests.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
@swrobel
swrobel / README.md
Last active May 25, 2018 — forked from denvazh/README.md
Scheduled update for homebrew
View README.md

Scheduled updates for homebrew

This two launchdaemon scripts provide scheduled updates and upgrade for homebrew packages.

It will run in the following way:

  • brew update every day at 12:10
  • brew upgrade every day at 12:20

How to install

@swrobel
swrobel / 1-OpsWorksPapertrail.md
Last active Aug 29, 2015
Send OpsWorks log files to Papertrail using the remote_syslog gem
View 1-OpsWorksPapertrail.md
  1. Add remote_syslog to your Gemfile
  2. Add papertrail.rake to lib/tasks
  3. Add remote_syslog.yml to config/
  4. Add before_restart.rb to deploy/
  5. Set the PAPERTRAIL_PORT ENV var to the one provided by Papertrail for your system

Inspiration from Scott W. Bradley

@swrobel
swrobel / .1-OpsWorksAssetPrecompile.md
Last active Aug 29, 2015
Precompile assets locally but keep the manifest files in source control
View .1-OpsWorksAssetPrecompile.md

This setup will allow you to precompile assets locally and keep them separated depending on the environment. To precompile assets locally run RAILS_ENV=production COMPILE_ASSETS=1 rake assets:precompile. Using an ENV var like this removes the need for having therubyracer or some other javascript engine on your server instances since they aren't actually running the precompilation task.

@swrobel
swrobel / spree_1.3.3_to_2.0.4.md
Last active Dec 18, 2018
HOWTO: Upgrade Spree 1.3.3 to 2.0.4
View spree_1.3.3_to_2.0.4.md

HOWTO: Upgrade Spree 1.3.3 to 2.0.4

These steps were sufficient to upgrade Cult Cosmetics to Spree 2.0.4 from 1.3.3. Here are some details on our environment.

  • We only have single-variant products
  • We are not making use of stock locations (single warehouse)
  • Frontend entirely overridden w/ custom bootstrap layout
  • Braintree gateway
  • Rails 3.2.14
  • Upgraded from Ruby 1.9.3-p448 to 2.0.0-p247 in the process (no issues)
@swrobel
swrobel / spree2_orders_by_product.sql
Last active Dec 21, 2015
Number of orders by product in Spree 2.0+
View spree2_orders_by_product.sql
SELECT p.id,
sum(quantity) AS num_sold
FROM spree_orders o
JOIN spree_line_items li ON o.ID = li.order_id
JOIN spree_variants v ON li.variant_id = v.id
JOIN spree_stock_items i ON v.id = i.variant_id
JOIN spree_products p ON v.product_id = p.id
WHERE o.state = 'complete'
GROUP BY p.id
You can’t perform that action at this time.