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
DIR = '<project-root>' | |
files = Dir.glob("#{DIR}/**/*.scss") | |
files.each { |f| `sass-convert #{f} #{f.sub(/\.scss/, '.sass')}` unless File.exist?(f.sub(/\.scss/, '.sass')) } | |
# one-liner for CLI use | |
# ruby -e "Dir.glob('<project-root>/**/*.scss').each { |f| `sass-convert #{f} #{f.sub(/\.scss/, '.sass')}` unless File.exist?(f.sub(/\.scss/, '.sass')) }" |
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
/ Generate an HTML5 video tag with embedded Flash fallback | |
/ @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video HTML5 video tag spec | |
/ | |
/ @local [Hash] video Attribute hash for the `video` tag | |
/ @option video [Integer] :width (320) Width of the video tag in pixels | |
/ @option video [Integer] :height (240) Height of the video tag in pixels | |
/ | |
/ @local [Hash] src Mapping of source file types to URLs for source files | |
/ @option src [String] :mp4 URL of an MP4 source file for the video | |
/ @option src [String] :webm URL of a WebM source file for the video |
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
- pages = sitemap.resources.find_all{|p| p.source_file.match(/\.html/) } | |
doctype xml | |
urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" | |
- pages.each do |p| | |
url | |
loc "http://www.YOUR_WEBSITE_URL/#{p.destination_path.gsub('/index.html','')}" | |
lastmod = Date.today.to_time.iso8601 | |
changefreq = p.data.changefreq || 'weekly' | |
priority = p.data.priority || '0.5' |
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
# allows one to specify the working directory for command execution | |
def execute_at(path, cmd) | |
execute "cd #{path} && #{cmd}" | |
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
# @param [Array<Integer>] List of sizes of the partitions self will be subdivided into | |
# @return [Object] Array containing self divided into one or more sub-arrays of size n | |
# @example | |
# [1,2,3].subdv [1] #=> [[1]] | |
# [1,2,3].subdv [3] #=> [[1,2,3]] | |
# [1,2,3].subdv [1,2] #=> [[1],[2,3]] | |
# [1,2,3].subdv [1,2] #=> [[1],[2,3]] | |
# [1,2,3].subdv [1,1,1] #=> [[1],[2],[3]] | |
# [1,2,3].subdv [1,2,1] #=> [[1],[2,3],[]] | |
def subdv(arr) |
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
# @param [Integer] n Number of times to call zip upon self | |
# @return [#zip] Self, after calling Array#zip upon self given number of times | |
def zipr(n = self.length) | |
r = self | |
n.times { r = r.zip } | |
r | |
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
# @return [Array] Two-member Array containing self evenly split into two sub-arrays | |
# @example | |
# [1,2,3,4].halves #=> [[1,2],[3,4]] | |
# [1,2,3].halves #=> [[1,2],[3]] | |
def halves | |
[self[0..(self.size/2.0).round-1], self[(self.size/2.0).round..self.size]] | |
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
/** | |
* Constructs and returns an HTML element wrapped in a jQuery object | |
* | |
* @param {String} tag Name of the HTML element | |
* @param {Object} attr Map of attribute key/value pairs for the HTML element | |
* @param {String} content Content to be directly inserted inside HTML tags | |
*/ | |
function htmlElem(tag, attr, content) { | |
tag = tag || 'div'; attr = attr || ''; content = content || ''; // optional parameters | |
var htmlString = '<' + tag |
NewerOlder