This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Blunder | |
# Centralizes error reporting, so we don't get custom | |
# library names like BugSnag or Errplane all over our code | |
def self.oops(exception, custom_data = {}) | |
raise if Rails.env == 'test' | |
exception = Exception.new(exception) unless exception.is_a?(Exception) | |
custom_data = custom_data.with_indifferent_access | |
Rails.logger.error("\n\nBlunder Exception: #{exception}") | |
Rails.logger.error("backtrace:#{exception.backtrace.take(20).join("\n")}\n\n") if exception.backtrace.present? | |
env = custom_data.delete(:env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open3' | |
# things herbalizer hates: | |
# nested hashes: %div{data: {href: src }} -> %div{data: Hash[href: src] } | |
# comments in the first line | |
# blank first line | |
# ruby-style interpolation: Message to #{person} -> Message to \ = person | |
# ternary operators inside blocks: %div{href: one ? two : three } -> put on separate line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = document.createElement('script'); | |
s.setAttribute('src','http://prose.atevans.com/bookmarklet.js'); | |
document.head.appendChild(s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def metroify(collection, partial, opts = {}) | |
return "" unless collection.present? | |
output = "" | |
coll_copy = collection.dup | |
renderize = lambda do |obj, tile| | |
locals = {tile: tile} | |
locals = locals.merge(opts[:locals]) if opts[:locals] | |
render_opts = opts.dup.merge(partial: partial, object: obj, locals: locals) | |
render(render_opts).to_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if params['format'] == 'base64' || params[:image].is_a?(String) | |
img = Magick::Image.read_inline(params[:image]) | |
fn = params['filename'] | |
else | |
img = img = Magick::Image.from_blob(params[:image][:tempfile].read) | |
fn = params[:image][:filename] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uploadImage = function(){ | |
$(".alert").remove(); | |
var img = $("#drop-target img").first(); | |
if(typeof(img) == "undefined" || typeof(img) == "null") { | |
alertBox("Can't seem to find your image."); | |
return false; | |
} | |
var formData = new FormData(); | |
formData.append("images[]", img.attr('src')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gridify(collection, partial, opts = {}) | |
rows = [] | |
coll_copy = collection.dup | |
cols = opts[:cols] || 3 | |
begin | |
row = [] | |
cols.times { row << coll_copy.shift } | |
row.compact! | |
rows << row | |
end while coll_copy.present? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"><Code><Value>Receiver</Valu... xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalSer... xml:lang="en-US">The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.</Text></Reason></Fault> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'json' | |
unless ARGV.count > 1 | |
puts "Usage: json_diff.rb json_file_1.json json_file_2.json" | |
exit | |
end | |
def different?(a, b, bi_directional=true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Script to quickly generate a new post for Jekyll | |
# 2012 Andrew Evans - http://atevans.com | |
require "net/http" | |
require "uri" | |
require 'RMagick' | |
def titleize(str) |