This file contains hidden or 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
$fixers = [ | |
'psr0', // [PSR-0] Classes must be in a path that matches their namespace, be at least one namespace deep, and the class name should match the file name. | |
'encoding', // [PSR-1] PHP code MUST use only UTF-8 without BOM (remove BOM). | |
'short_tag', // [PSR-1] PHP code must use the long tags or the short-echo tags it must not use the other tag variations. | |
'braces', // [PSR-2] The body of each structure MUST be enclosed by braces. Braces should be properly placed. Body of braces should be properly indented. | |
'elseif', // [PSR-2] The keyword elseif should be used instead of else if so that all control keywords looks like single words. |
This file contains hidden or 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://example.com => https://example.com | |
# http://www.example.com => https://example.com | |
# https://www.example.com => https://example.com | |
# https://example.com => https://example.com | |
# everything goes to https://example.com | |
server { | |
server_name example.com.com www.example.com.com; | |
return 301 https://example.com.com$request_uri; | |
} |
This file contains hidden or 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 | |
namespace App\Models; | |
use Illuminate\Database\Eloquent\Model as Eloquent; | |
/** | |
* This class acts as our Base Model | |
* | |
* @package App\Models |
This file contains hidden or 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 = array('foo' => array('bar' => array('baz' => 1))); | |
function resolve(array $a, $path, $default = null) | |
{ | |
$current = $a; | |
$p = strtok($path, '.'); | |
while ($p !== false) { | |
if (!isset($current[$p])) { | |
return $default; |
This file contains hidden or 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
/** | |
* Computes the square root of a nonnegative number c using | |
* http://en.wikipedia.org/wiki/Newton's_method | |
* Newton's method: | |
* - initialize t = c | |
* - replace t with the average of c/t and t | |
* - repeat until desired accuracy reached | |
* | |
* % java Sqrt 2 | |
* 1.414213562373095 |
This file contains hidden or 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 | |
/** | |
* Get next working day. | |
* Does NOT account for holidays. | |
* @param $timestamp | |
* @param int $numDays | |
* @return int | |
*/ | |
function getNextWorkingDay($timestamp, $numDays = 1) { | |
// add the number of days passed but skip weekends |
This file contains hidden or 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 | |
/** | |
* Returns the number of days in a month | |
* @param $year | |
* @param $month | |
* @return $daysInMonth | |
*/ | |
function daysInMonth($year, $month) { | |
return date('t', strtotime($year.'-'.$month.'-01')); | |
} |
This file contains hidden or 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
-- TEMP TABLE FOR SELECTS | |
CREATE TEMPORARY TABLE temp_table AS | |
SELECT * FROM table1 a JOIN table2 b ON a.id = b.id; | |
SELECT * FROM temp_table; |