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
desc "Manage the encoding header of Ruby files" | |
task :utf8_encode_headers => :environment do | |
files = Array.new | |
["*.rb", "*.rake"].each do |extension| | |
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ]) | |
end | |
files.each do |file| | |
content = File.read(file) | |
next if content[0..16] == "# coding: UTF-8\n\n" || |
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
# In spec/support/callback_disabler.rb | |
module CallbackDisabler | |
def self.store_callbacks(model, filters) | |
model = constantize(model) | |
filters.each do |filter| | |
model.send("_#{filter}_callbacks").each do |callback| | |
stored_callbacks[model] << { | |
filter: filter, kind: callback.kind, raw_filter: callback.raw_filter | |
} |
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
// javascript jpeg decoder: https://github.com/eugeneware/jpeg-js/blob/79c4c7ea876d2e7b46981a563fcc4ae8f9e19849/lib/decoder.js | |
// Determine the JPEG compression quality from the quantization tables: https://github.com/ImageMagick/ImageMagick/blob/59f28acff016f6ae5e8b7e6300bcdf97e94affc9/coders/jpeg.c#L879 | |
// JPEG File Layout and Format: http://vip.sugovica.hu/Sardi/kepnezo/JPEG%20File%20Layout%20and%20Format.htm | |
// jpeg constants: https://github.com/LuaDist/libjpeg/blob/6c0fcb8ddee365e7abc4d332662b06900612e923/jpeglib.h#L45 | |
function getQuantizationTables(data) { | |
var quantizationTables = [] | |
var dctZigZag = new Int32Array([ |