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 | |
require 'Slim/Slim.php'; | |
$app = new Slim(); | |
$app->get('/hello/:name', function ($name) { | |
echo "Hello, $name!"; | |
}); | |
$app->run(); | |
?> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> | |
<title>My Document</title> | |
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> | |
<link rel="stylesheet" href="/css/all.css"/> | |
<link rel="shortcut icon" href="/images/favicon.ico"/> |
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
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ | |
window.log = function () { | |
log.history = log.history || []; | |
log.history.push(arguments); | |
if (this.console) { | |
console.log(Array.prototype.slice.call(arguments)); | |
} | |
}; |
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
DROP TABLE IF EXISTS table_name; | |
CREATE TABLE table_name ( | |
) ENGINE=INNODB DEFAULT CHARSET=UTF8 COLLATE=UTF8_UNICODE_CI; |
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
/** | |
* 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
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
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
/** | |
* 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) { |
OlderNewer