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 class for turning timestamps into more user-friendly relative dates. | |
* | |
$date = new Relative_Date(); | |
echo $date->relative_formatted_date; //"Today" | |
*/ | |
class Relative_Date { | |
const DAY = 86400; |
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 calculate_bmi(weight_in_pounds, height_in_inches) | |
return ((weight_in_pounds.to_f/height_in_inches.to_f**2) * 703) | |
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
var REFLOW = (function(window, $){ | |
var self = {}; | |
var nth; | |
var itemsAfterFirstRow; | |
var allItems = $('#items .col'); | |
self.init = function(){ | |
self.adjustHeights(); | |
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
# This script uses the Plos.org API to collect article data. | |
# Necessary libraries | |
require 'csv' | |
require 'work_queue' | |
require 'rest-client' | |
# The file name for the CSV file that will be READ | |
CSV_FILENAME = "9_10_2014-Cumulative-Report-With-Subject-Area-and-Article-Type.csv" | |
# The file name for the CSV file that will be WRITTEN | |
CSV_OUTPUT_FILENAME = "9_10_2014-Cumulative-Report-With-ALM-Data.csv" |
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
# This script scrapes the PlosOne.org website to extract data for articles. At the time, this data was not available in the API. | |
# Necessary libraries | |
require 'CSV' | |
require 'nokogiri' | |
require 'open-uri' | |
require 'work_queue' | |
require 'benchmark' | |
CSV_FILENAME = "9_10_2014-Cumulative-Report.csv" |
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(document.body).on("mouseup", function(){ console.time("Tab showing") }); | |
jQuery(".nav-tabs li:nth-child(1)").on("mouseup", function(){ console.timeEnd("Tab showing"); }) | |
var target = document.querySelector(".nav-tabs li:nth-child(2)"); | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
console.timeEnd("Tab showing"); | |
}); | |
}); |
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 href="#nogo" class="button--PRIMARY">Primary Button</a> | |
<br /> | |
<a href="#nogo" class="button--SECONDARY">Secondary button</a> |
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 prevent_widows(text) | |
if text.kind_of? String | |
trimmed_text = text.rstrip | |
last_space_index = trimmed_text.rindex(" ") | |
if !last_space_index.nil? | |
text[last_space_index] = " " | |
end | |
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
//assume variables currentIndex, nextIndex, arrayLength exist | |
//moving "forward", positive incrementing | |
nextIndex = (currentIndex + 1) % arrayLength; | |
//moving "backward", negative incrementing | |
if(currentIndex == 0){ | |
nextIndex = arrayLength - 1; | |
} else { | |
nextIndex = (currentIndex - 1) % arrayLength; |
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 alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; | |
var rot13 = function(letter){ | |
var l = letter.toLowerCase(); | |
var index = alphabet.indexOf(l); | |
var newIndex = (index + 13) % alphabet.length; | |
return alphabet[newIndex]; |
OlderNewer