Skip to content

Instantly share code, notes, and snippets.


Stefan Wrobel swrobel

View GitHub Profile
swrobel / gemfile_changelog.rb
Created Mar 23, 2012
Get Changelogs for outdated gems in Gemfile
View gemfile_changelog.rb
#!/usr/bin/env ruby
def changelog_for_gem(gem)
changelogs = `bundle exec gem contents #{gem}`.lines.grep(/history|changelog|news/i)
if changelogs.empty?
puts "No changelog found for gem #{gem}"
return nil
swrobel / copy_db.sql
Created Mar 23, 2012
MySQL script to copy from one database to another in pure SQL
View copy_db.sql
DECLARE found_count,ndx,ndx_last INT;
DECLARE sqlcmd VARCHAR(1024);
SELECT COUNT(1) INTO found_count
FROM information_schema.tables
View Mou Twilight+.txt
foreground: F8F8F8
background: 141414
caret: A7A7A7
background: 33363a
foreground: 5F5A60
View responsive-mixin.scss
$phone: '(max-width: 480px)';
$tablet-portrait: '(max-width: 767px)';
$tablet-landscape-desktop: '(min-width: 768px) and (max-width: 979px)';
$large-desktop: '(min-width: 1200px)';
$non-retina: 'screen and (-webkit-max-device-pixel-ratio: 1)';
$retina: 'screen and (-webkit-min-device-pixel-ratio: 2)';
@mixin respond-to($media) {
@media #{$media} {
swrobel /
Last active Dec 16, 2015
Toggle airport depending on wired network status. Works on Retina Macbooks using thunderbolt ethernet adapter (en3). Airport should be en0.
  1. sudo mv /Library/Scripts/
  2. sudo chmod 755 /Library/Scripts/
  3. sudo mv com.mine.toggleairport.plist /System/Library/LaunchAgents/
  4. sudo chown root:wheel /System/Library/LaunchAgents/com.mine.toggleairport.plist
  5. sudo launchctl load /System/Library/LaunchAgents/com.mine.toggleairport.plist

The script should run on startup and give you growl notifications when airport status is changed if you have GrowlNotify installed

Credit to

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
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 =
JOIN spree_stock_items i ON = i.variant_id
JOIN spree_products p ON v.product_id =
WHERE o.state = 'complete'
swrobel /
Last active Dec 18, 2018
HOWTO: Upgrade Spree 1.3.3 to 2.0.4

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 /
Last active Aug 29, 2015
Precompile assets locally but keep the manifest files in source control

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 /
Last active Aug 29, 2015
Send OpsWorks log files to Papertrail using the remote_syslog gem
  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 /
Last active May 25, 2018 — forked from denvazh/
Scheduled update for homebrew

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