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
^([^:]+:\/\/)([^@]+\@)?([^:\/]+)(:\d+)?(\/[^\s\?\#]+)+(\?([^\n\#]+)(\#\S+)?|(\#\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
class Hash | |
# gets hash-nested values, returns nil if any key is missing | |
def dig(*path) | |
path.inject(self) do |location, key| | |
location.respond_to?(:keys) ? location[key] : nil | |
end | |
end | |
# Deletes key from self and returns self | |
def kill(key) |
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
// A bunch of functions you can use in the MongoDB shell | |
// taken from http://api.mongodb.org/js/1.8.2/index.html | |
// amongst other sources | |
// Used in place of print() to view the contents of objects | |
printjson(x); | |
printjsononeline(x); | |
// File system interaction | |
ls(...); |
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) |
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
<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
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
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
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
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 |
OlderNewer