Skip to content

Instantly share code, notes, and snippets.

View johnbintz's full-sized avatar

John Bintz johnbintz

View GitHub Profile
@johnbintz
johnbintz / Cardfile.rb
Created November 17, 2013 18:10
Example Cardfile for SVGGVS
@session.configure do |c|
c.svg_source = "template.svg"
c.svg_merged_target = "merged-template.svg"
c.png_export_width = 825
c.pdf_dpi = 300
c.pdf_card_size = "750x1050"
c.individual_files_path = "svgout/output_%03d.svg"
class SearchController < ApplicationController
def index
@search = MultiSearch.new(params[:query])
# ... do things to @search maybe ...
# ... or hand it off to a decorator ...
end
end
@johnbintz
johnbintz / gist:6382319
Last active December 21, 2015 23:29
Process a directory of images, color correcting for printout, for TGC use
# your source PNG files are in the input directory
mkdir -p output
for file in input/*.png; do
filename=${file##*/}
convert "${file}" -level "0%,100%,1.5" "output/${filename}"
# what the heck, make them smaller, too
@johnbintz
johnbintz / 01-original-jquery.coffee
Last active December 20, 2015 14:29
Going from pure jQuery to AngularJS
$(->
# set up or retrieve our local storage
navStatus = $.totalStorage('left_nav') || {}
# set up the initial state of each site opener and nav links
for id, status of navStatus
siteLink = $("#user_sites [data-id='#{id}']")
opener = siteLink.prev()
opener.toggleClass('open', status)
@johnbintz
johnbintz / Thorfile
Created July 23, 2013 02:36
Process a directory of PNG card files from nanDECK for The Game Crafter
require 'quick_magick'
class CardsBuilder < Thor
no_tasks do
def bordersize(image, color = image.get_pixel(0, 0))
image.gravity = 'center'
image.background = "rgb(#{color.join(',')})"
image.extent "825x1125"
end
end
@johnbintz
johnbintz / cards.rb
Last active December 19, 2015 14:09
Basic Ruby script to create cards for nanDECK from Google Drive spreadsheet data
CARD_INFO = {
animal: { color: '#aa0000', border: '#ff0000' },
vegetable: { color: '#00aa00', border: '#00ff00' },
mineral: { color: '#0000aa', border: '#0000ff' }
}.freeze
# install this as a standalone gem
# or use a Gemfile and bundle exec with this script
require 'google_drive'
@johnbintz
johnbintz / gist:5950149
Created July 8, 2013 16:07
Totally untested way to run Rack and a LiveReload listener for rack-livereload testing
LIVERELOAD_PORT = 50000
app = Rack::LiveReload.new(
lambda { |env|
[
200,
{ 'Content-Type' => 'text/html' },
[ <<-HTML ]
<html>
<head>
@johnbintz
johnbintz / cards.rb
Last active December 18, 2015 13:49
Basic Ruby script for generating nanDECK cards (untested)
CARD_INFO = {
animal: { color: '#aa0000', border: '#ff0000' },
vegetable: { color: '#00aa00', border: '#00ff00' },
mineral: { color: '#0000aa', border: '#0000ff' }
}.freeze
data = [
{ name: 'Cat', value: '1', type: :animal },
{ name: 'Rutabaga', value: '2', type: :vegetable },
{ name: 'Obsidian', value: '3', type: :mineral }
@johnbintz
johnbintz / hooks.rb
Created May 17, 2013 14:44
Autogenerate and autosort missing i18n translation keys for a Rails application while running Cucumber features
# Put this in features/support/hooks.rb and add i18n-missing_translations and i18n_yaml_sorter to your Gemfile
require 'i18n/missing_translations'
require 'i18n_yaml_sorter'
at_exit do
require 'yaml'
data = YAML.load_file('config/locales/en.yml')
data.deep_merge!(I18n.missing_translations)
@johnbintz
johnbintz / active_admin_ckeditor_patch.css.scss
Last active December 16, 2015 00:19 — forked from SebAshton/active_admin_ckeditor_patch.css.scss
More complete and Sass-y fix for Ckeditor in Active Admin.
body.active_admin {
.cke {
display: inline-block;
table { width: auto; }
width: 78%;
}
.cke_button_label {