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
// Load the original image from disk | |
using (Image originalImage = Image.FromFile(Server.MapPath("~/App_Data/" + file.FileName))) | |
{ | |
// Apply the queued transformations to the original image | |
using (Image newImage = filters.Apply(originalImage)) | |
{ | |
return File(newImage.ToByteArray(), file.ContentType); | |
} | |
} |
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
Given /^I visit subdomain "(.+)"$/ do |sub| | |
#host! "#{sub}.example.com" #for webrat | |
Capybara.default_host = "#{sub}.example.com" #for Rack::Test | |
Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :culerity | |
################################################################################ | |
# As far as I know, you have to put all the {sub}.example.com entries that you're | |
# using in your /etc/hosts file for the Culerity tests. This didn't seem to be | |
# required for Rack::Test | |
################################################################################ |
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
# Example implementation, ignoring the less important details: | |
class MyTree | |
include Mongoid::Document | |
include Mongoid::Tree | |
referenced_in :account, :inverse_of => :trees | |
field :slug | |
scope :slugged, lambda { |s, options={}| where(options.merge(:slug => s)).first } |
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
// jQuery barfs because $(empty).data("autocomplete") => undefined | |
$(".course-autocomplete").autocomplete({ | |
source: "/courses/autocomplete.json" | |
}).data("autocomplete")._renderItem = function(ul, item) { | |
return $("<li>") | |
.data("item.autocomplete", item) | |
.append("<a>" + item.name + "</a>") | |
.appendTo(ul); | |
}; |
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
first = ["t", "o", "p", "c", "o", "d", "e", "r", "s", "i", "n", "g", "l", "e", "r", | |
"o", "u", "n", "d", "m", "a", "t", "c", "h", "f", "o", "u", "r", "n", "i"] | |
second = ["n", "e", "f", "o", "u", "r", "j", "a", "n", "u", "a", "r", "y", "t", "w", | |
"e", "n", "t", "y", "t", "w", "o", "s", "a", "t", "u", "r", "d", "a", "y"] | |
hash = Hash.new(0) | |
(first + second).each_with_index do |element, i| | |
hash[element] += 1 | |
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
_getObjectAttr: function () { | |
var object = {}, | |
formValues = this.get("value"); | |
for (name in formValues) { | |
if (formValues.hasOwnProperty(name)) { | |
var nameParts = name.replace(/\]/g, '').split('['), | |
building = object; | |
dojo.forEach(nameParts, function (part, idx) { |
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
(function () { | |
// Static list across all Persons? | |
var pets = [ ]; | |
dojo.declare("Person", null, { | |
} | |
}()); |
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
fromString: function (dateString) { | |
if (!dateString) { return new Date(); } | |
// IE/Safari expects "2011/05/03 09:03:21-0500" | |
if (dojo.isIE || dojo.isSafari) { | |
// Replace hyphens with forward slashes (2011-05-03 => 2011/05/03) | |
dateString = dateString.replace(/^(\d{4})-(\d{2})-(\d{2})/, "$1/$2/$3"); | |
// Replace T prefixing time with a space (T09:03:21 => " 09:03:21") | |
dateString = dateString.replace(/T(\d+:\d+:\d+)/, " $1"); | |
// Remove colon in timezone (-05:00 => -0500) |
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
require 'java' | |
require 'jodconverter-cli-2.2.1.jar' | |
def convert(file_in,file_out) | |
inputFile = java.io.File.new(file_in) | |
outputFile = java.io.File.new(file_out) | |
# connect to an OpenOffice.org instance running on port 8100 | |
connection = com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection.new(8100) | |
connection.connect() |
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
require 'java' | |
require 'jodconverter-cli-2.2.1.jar' | |
def convert(file_in,file_out) | |
inputFile = java.io.File.new(file_in) | |
outputFile = java.io.File.new(file_out) | |
# connect to an OpenOffice.org instance running on port 8100 | |
connection = com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection.new(8100) | |
connection.connect() |
OlderNewer