Skip to content

Instantly share code, notes, and snippets.

Cristiano Diniz da Silva mcloide

Block or report user

Report or block mcloide

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mcloide
mcloide / comparison.php
Last active Apr 11, 2016
PHP Datetime comparison unexpected behavior
View comparison.php
<?php
foreach (['EST', 'EDT', 'CST', 'CDT', 'PST', 'PDT'] as $tz) {
echo "---- TZ: $tz ---- \n";
$now = new DateTime('@' . (new DateTime('11:30 AM EST'))->getTimeStamp());
$earlier = new DateTime('7 AM', new DateTimeZone($tz));
echo $now->format('r') . "\n";
echo $earlier->format('r') . "\n";
View gist:2120477b045a7574db7b
update piratees p
join (
select p1.id, min(ps.ship_in) as ship_in
from piratees p1
join piratee_login ps on ps.piratee_id = p1.id
where ps.ship_in is not null
and ps.ship_in > '1970-01-01 00:00:01'
group by p1.id
) as ps
on ps.id = p.id
View gist:a971d50af6dda3a5e3b6
update piratees p
join (
select p1.id, min(ps.ship_in) as ship_in
from piratees p1
join piratee_login ps on ps.piratee_id = p1.id
where ps.ship_in is not null
and ps.ship_in != '0000-00-00 00:00:00'
group by p1.id
View gist:4702c9b628cf9d7d50b6
+----+---------------------+---------------+------------+--------------+---------+----+---------------------+
| id | created_date | modified_date | start_date | fname | lname | id | ship_in |
+----+---------------------+---------------+------------+--------------+---------+----+---------------------+
| 1 | 0000-00-00 00:00:00 | NULL | 0000-00-00 | Captain Jack | Sparrow | 1 | 2016-03-22 01:15:07 |
| 2 | 0000-00-00 00:00:00 | NULL | 0000-00-00 | Captain | Barbosa | 2 | 2016-03-22 01:15:17 |
+----+---------------------+---------------+------------+--------------+---------+----+---------------------+
2 rows in set, 1 warning (0.00 sec)
View gist:00448dcaabb8a2b8d379
select * -- please don't ever do *
from piratees p
join (
select p1.id, min(ps.ship_in) as ship_in
from piratees p1
join piratee_login ps on ps.piratee_id = p1.id
where ps.ship_in is not null
and ps.ship_in != '0000-00-00 00:00:00'
group by p1.id
) as ps
View gist:1dec58a100b47da7c8ad
+----+---------------------+---------------+------------+--------------+---------+----+---------------------+---------------------+------------+---------------------+---------------------+
| id | created_date | modified_date | start_date | fname | lname | id | created_date | modified_date | piratee_id | ship_in | ship_out |
+----+---------------------+---------------+------------+--------------+---------+----+---------------------+---------------------+------------+---------------------+---------------------+
| 1 | 0000-00-00 00:00:00 | NULL | 0000-00-00 | Captain Jack | Sparrow | 1 | 2016-03-22 01:14:53 | 2016-03-22 01:14:53 | 1 | 0000-00-00 00:00:00 | 2016-03-22 01:14:53 |
| 1 | 0000-00-00 00:00:00 | NULL | 0000-00-00 | Captain Jack | Sparrow | 2 | 2016-03-22 01:15:07 | 2016-03-22 01:15:07 | 1 | 2016-03-22 01:15:07 | 2016-03-22 01:15:07 |
| 2 | 0000-00-00 00:00:00 | NULL | 0000-00-00 | Captain | Barbos
View gist:656fccf09d3ec2efc65f
STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
View gist:1bf0a0433c6d834965cc
NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
@mcloide
mcloide / caribbean.sql
Last active Mar 22, 2016
Caribbean DB Structure
View caribbean.sql
-- MySQL dump 10.13 Distrib 5.6.28, for Linux (x86_64)
--
-- Host: localhost Database: caribbean
-- ------------------------------------------------------
-- Server version 5.6.28
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
View gist:5828495
------------------
System Information
------------------
Time of this report: 1/25/2013, 16:51:06
Operating System: Windows 7 Professional 64-bit (6.1, Build 7601) Service Pack 1 (7601.win7sp1_gdr.120830-0333)
Language: English (Regional Setting: English)
System Manufacturer: CLEVO CO.
System Model: W35_37ET
BIOS: BIOS Date: 10/26/12 14:53:27 Ver: 04.06.05
Processor: Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz (8 CPUs), ~2.4GHz
You can’t perform that action at this time.