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
egrep -lRZ "\.jpg|\.png|\.gif" . \ | |
| xargs -0 -l sed -i -e 's/\.jpg\|\.gif\|\.png/.bmp/g' | |
#egrep: find matching lines using extended regular expressions | |
# -l: only list matching filenames | |
# -R: search recursively through all given directories | |
# -Z: use \0 as record separator | |
# "\.jpg|\.png|\.gif": match one of the strings ".jpg", ".gif" or ".png" | |
# .: start the search in the current directory | |
#xargs: execute a command with the stdin as argument |
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
job_type :delayed_job, 'cd :path && RAILS_ENV=:environment script/delayed_job :task' | |
every :reboot do | |
delayed_job 'start', :environment => 'development' | |
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
# Thanks to Steve Weet's answer on Stack Overflow: | |
# http://stackoverflow.com/questions/3375360/how-to-redefine-a-ruby-constant-without-warning | |
module RemovableConstants | |
def def_if_not_defined(const, value) | |
self.class.const_set(const, value) unless self.class.const_defined?(const) | |
end | |
def redef_without_warning(const, value) | |
self.class.send(:remove_const, const) if self.class.const_defined?(const) | |
self.class.const_set(const, value) |
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 formatSecondsAsTime(secs, format) { | |
var hr = Math.floor(secs / 3600); | |
var min = Math.floor((secs - (hr * 3600))/60); | |
var sec = Math.floor(secs - (hr * 3600) - (min * 60)); | |
if (hr < 10) { hr = "0" + hr; } | |
if (min < 10) { min = "0" + min; } | |
if (sec < 10) { sec = "0" + sec; } | |
if (hr) { hr = "00"; } |
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
// Array.splice(index, howmany, element_to_add_1,.....,element_to_add_X) | |
// Reference: http://www.w3schools.com/jsref/jsref_splice.asp | |
var myArray = [4,5,6]; | |
var idx = visibleIds.indexOf(5); // Find the index | |
if(idx!=-1) visibleIds.splice(idx, 1); // Remove it! Returns --> [5] | |
// visibleIds is now --> [4, 6] |
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
Number.prototype.number_with_delimiter = function(delimiter) { | |
var number = this + '', delimiter = delimiter || ','; | |
var split = number.split('.'); | |
split[0] = split[0].replace( | |
/(\d)(?=(\d\d\d)+(?!\d))/g, | |
'$1' + delimiter | |
); | |
return split.join('.'); | |
}; |
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
# One row | |
["Quid, quid", "latinum dictum"].to_csv | |
#Multiple Rows | |
FasterCSV.generate(:col_sep=>',', :quote_char => '"') do |row| | |
row << ["Quid, quid", "latinum dictum"] | |
row << ["sit, altum", "viditur."] | |
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
# Thanks to Henning Koch: https://makandracards.com/makandra/763-cucumber-step-to-match-table-rows-with-capybara | |
module ArrayMethods | |
def find_row(expected_row) | |
find_index do |row| | |
expected_row.all? do |expected_column| | |
first_column = row.find_index do |column| | |
content = column.content.gsub(/[\r\n\t]+/, ' ').gsub(/[ ]+/, ' ').strip | |
expected_content = expected_column.gsub(' ', ' ').strip | |
matching_parts = expected_content.split('*', -1).collect { |part| Regexp.escape(part) } | |
matching_expression = /\A#{matching_parts.join(".*")}\z/ |
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
// REQUIRES: | |
// http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js | |
// http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js | |
// Based on: https://gist.github.com/1395926 | |
$(document).ready(function() { | |
$('.gist').each(function(i) { | |
var file_separator = $(this).text().indexOf('#'); | |
if (file_separator != -1) { | |
var gist_url = $(this).text().slice(0, file_separator); | |
var gist_file = $(this).text().slice(file_separator).replace("#file_", "?file="); |
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
# put this in `features/support/env.rb` | |
Capybara.register_driver :chrome do |app| | |
args = [] | |
args << "--user-agent='Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile /9A334 Safari/7534.48.3'" | |
Capybara::Selenium::Driver.new(app, {:browser => :chrome, :args => args}) | |
end | |
Before('@mobile') do | |
Capybara.current_driver = :chrome | |
end |
OlderNewer