Skip to content

Instantly share code, notes, and snippets.

View rjswenson's full-sized avatar

Robin S. Healey rjswenson

  • Internet Superhighway
  • USA
View GitHub Profile
@rjswenson
rjswenson / screenshot-capture-selection.sh
Created May 31, 2016 18:31 — forked from justsml/screenshot-capture-selection.sh
Linux/Debian Clone of Mac OSX 'Capture Screen Region' feature (map to similar Cmd+Ctrl+Shift+4)
#!/bin/bash
# Clone of Capture Screen Region on Mac OSX (map to similar Cmd-Ctrl-Shift-4)
# *** Requirements ***
# shutter - `apt-get install shutter`
# copyq - download from https://github.com/hluk/CopyQ/releases
shutter --select --no_session --exit_after_capture --output=/tmp/screenshot-surrent.png
copyq write image/png - < /tmp/screenshot-surrent.png && copyq select 0
rm /tmp/screenshot-surrent.png
@rjswenson
rjswenson / bash-cheatsheet.sh
Created May 3, 2016 22:39 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@rjswenson
rjswenson / change_wo_callbacks.rb
Created October 9, 2015 23:08
Change Mongoid object w/o callbacks
#
Document.where(:wholesale_price_group.ne => nil, :total_prices.ne => {}).each do |doc|
wsl = doc.total_prices[doc.wholesale_price_group]
Document.collection.where({_id: doc.id}).update({
"$set" => { :wholesale_total => wsl }
})
end
def assemble_ii(item)
match = item.class.to_s.match('Inventory([0-9]+)')[1]
if match == "05"
region = "-#{match}"
else
region = ""
end
@ii = {
key: item.upc,
@rjswenson
rjswenson / nested_dup.rb
Created August 27, 2015 21:56
Mongoid nested_dup
def nested_dup
dup_dash_hash = self.dup.as_document
children_hash.each do |key, child_object|
dup_dash_hash["#{key.to_s}_attributes"] = child_object.dup.as_document
end
new_dash = Dashboard::Component::Wrapper.new(dup_dash_hash)
new_dash.carousel.items.map {|it| it.image.reprocess! }
new_dash.content_ribbon.items.map {|it| it.image.reprocess! }
@rjswenson
rjswenson / dashboards_spec.md
Last active August 29, 2015 14:22
dashboards_spec.md

Models

####DashboardComponent::Base

  • accept and descend 'tags' throughout dashboard
  • handle user-specific 'dashboards'
    • include Rules Module

####DashboardComponent::Wrapper

Paperclip.interpolates :altered_image_filename do |attachment, style|
# The change is at the very end here
attachment.instance.original_filename.match(/([A-Za-z0-9]+_)?[A-Za-z0-9]+_[a-zA-Z0-9]+_[PSA](_[0-9]+)?/).to_s + ".png"
end
#^~~~~~~~~^
@rjswenson
rjswenson / gist:8897a0eb86803dd28c06
Last active August 29, 2015 14:15
restart_sidekiqs.sh
#!/bin/bash
set -f
echo 'Iterating through all Sidekiq screens' >&2
for i in $( screen -ls sidekiq| grep -o [0-9]*.sidekiq\-[a-z]*); do
SCREEN_ID=$(echo $i | grep -oE "(^[0-9]+)")
CLIENT=$(echo $i | grep -oE "([a-z]+)$")
echo "starting screen: ${i}"
@rjswenson
rjswenson / kill_me.rb
Created November 18, 2014 03:55
Remove all image files not matching Product number regex
prod_nums = Product.all.map(&:number).uniq
image_files = Dir.entries("data/products")
image_files.delete(".")
image_files.delete("..")
image_files.each do |imf|
unless prod_nums.include?(imf.split('_')[0])
File.delete("data/products/#{imf}"
@rjswenson
rjswenson / active_admin_column_update.js
Created November 11, 2014 17:21
Active Admin in column updates!
//= require active_admin/base
var admin = {
init: function(){
admin.set_admin_editable_events();
},
set_admin_editable_events: function(){
$(".admin-editable").on("keypress", function(e){
if ( e.keyCode==27 )