Skip to content

Instantly share code, notes, and snippets.

View LoicMahieu's full-sized avatar
🙈
🙊

Loïc Mahieu LoicMahieu

🙈
🙊
View GitHub Profile
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
// OUTPUT:
// Executing: DROP TABLE IF EXISTS `Persons`;
// Executing: CREATE TABLE IF NOT EXISTS `Persons` (`name` VARCHAR(255), `id` INTEGER NOT NULL auto_increment , `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
// Executing: DROP TABLE IF EXISTS `Pets`;
// Executing: CREATE TABLE IF NOT EXISTS `Pets` (`name` VARCHAR(255), `id` INTEGER NOT NULL auto_increment , `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `PersonId` INTEGER, PRIMARY KEY (`id`)) ENGINE=InnoDB;
// Executing: INSERT INTO `Persons` (`name`,`id`,`createdAt`,`updatedAt`) VALUES ('Luke',NULL,'2013-05-29 11:00:37','2013-05-29 11:00:40');
// Executing: INSERT INTO `Pets` (`name`,`id`,`createdAt`,`updatedAt`,`PersonId`) VALUES ('Bob',NULL,'2013-05-29 11:00:37','2013-05-29 11:00:40',NULL);
// Executing: SELECT * FROM `Pets` WHERE `Pets`.`PersonId`=1;
@LoicMahieu
LoicMahieu / gist:4494861
Last active December 10, 2015 21:29
determineDate(date, refDate, defaultDate) Usage: determineDate('+1y') = now + 1 year determineDate('+1d', new Date(2012, 1, 1)) == 2012-01-02
function determineDate(date, refDate, defaultDate) {
var getDaysInMonth = function (year, month) {
var date = new Date(year, month, 32);
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
return 32 - date.getDate();
},
offsetNumeric = function (offset, date) {
date.setDate(date.getDate() + offset);
return date;
},
@LoicMahieu
LoicMahieu / backgroundClipText
Created February 13, 2012 21:08
BackgroundClipText - Modernizr Test
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BackgroundClipText - Modernizr Test</title>
<script src="modernizr.js"></script>
<script>
function getBgClipValue(elem){
return (
@LoicMahieu
LoicMahieu / backgroundClipText
Created February 13, 2012 21:08
BackgroundClipText - Modernizr Test
<!DOCTYPE HTML PUBLIC>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BackgroundClipText - Modernizr Test</title>
<script src="modernizr.js"></script>
<script>
function getBgClipValue(elem){
return (