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 string_to_slug (str) { | |
str = str.replace(/^\s+|\s+$/g, ''); // trim | |
str = str.toLowerCase(); | |
// remove accents, swap ñ for n, etc | |
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"; | |
var to = "aaaaeeeeiiiioooouuuunc------"; | |
for (var i=0, l=from.length ; i<l ; i++) { | |
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); | |
} |
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 roundToNearestMinute = function (date) { | |
var coeff = 1000 * 60 * 5; // <-- Replace {5} with interval | |
return new Date(Math.round(date.getTime() / coeff) * coeff); | |
}; |
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
<select name="state"> | |
<option value="" selected="selected">Select a State</option> | |
<option value="AL">Alabama</option> | |
<option value="AK">Alaska</option> | |
<option value="AZ">Arizona</option> | |
<option value="AR">Arkansas</option> | |
<option value="CA">California</option> | |
<option value="CO">Colorado</option> | |
<option value="CT">Connecticut</option> | |
<option value="DE">Delaware</option> |
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
<?php | |
class CsvIterator implements \Iterator | |
{ | |
const ROW_SIZE = 4096; | |
/** | |
* The pointer to the cvs file. | |
* @var resource | |
* @access protected | |
*/ |
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
if ('geolocation' in navigator) { | |
console.log('Supports HTML geolocation API'); | |
(function () { | |
var onSuccess = function (location) { | |
console.log('User location', location); | |
var userLat = location.coords.latitude, | |
userLon = location .coords.longitude; | |
}, |
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
# Views and Blocks | |
* Cache views | |
* Export views to code | |
* Revert views to code | |
# Performance | |
* Enable page cache | |
* Enable block cache |
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
/** | |
* Geocode address | |
* | |
* REQUIREMENTS | |
* - Google Maps API | |
* - HTML5 Geolocation API | |
*/ | |
var geocode = function (address, onSuccess, onError) { | |
var geocoder = new google.maps.Geocoder(); | |
geocoder.geocode({ address: address }, function (results, status) { |
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
/** | |
* CSV upload and parser | |
* | |
* This code will use the HTML5 File and FileReader APIs | |
* to upload and parse a CSV file. | |
* | |
* REQUIREMENTS: | |
* - jQuery | |
* - D3.js | |
* - HTML5 File APIs |
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
Verifying that +codeguy is my blockchain ID. https://onename.com/codeguy |
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
placeholderSupport = ("placeholder" in document.createElement("input")); | |
if (placeholderSupport === false) { | |
$('[placeholder]').each(function () { | |
var $input = $(this), | |
placeholder = $input.attr('placeholder'); | |
$input | |
.val(placeholder) | |
.focus(function () { |
NewerOlder