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
-- For example, a members table that has duplicate emails | |
-- Needs unique id field to work | |
create temporary table tmpTable (id int); | |
insert tmpTable | |
(id) | |
select id | |
from members m | |
where exists |
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
ALTER TABLE XXX add column id INT NOT NULL AUTO_INCREMENT FIRST, ADD primary KEY Id(id) |
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 (App::environment() == 'local') | |
@foreach (DB::getQueryLog() as $query) | |
<script>console.log(' {{ $query['query'] . ' (' . $query['time'] . ' secs)' }} ')</script> | |
@endforeach | |
@endif |
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
<overview> | |
pf = new function | |
comm = new function comment | |
fopen = open a form | |
fclose = close a form | |
</overview> | |
<snippet> | |
<content> | |
<![CDATA[ |
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 | |
/** | |
* Helpers for Laravel 4 | |
* Author: Anthony Vipond | |
*/ | |
// Preformat the dump and die function | |
if (!function_exists('d')) { | |
function d($mixed) { |
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 | |
/** | |
* Author: Anthony Vipond | |
* Tested on: PHP 5.5 | |
*/ | |
$global_indexes = ['SERVER', 'ENV', 'SESSION', 'REQUEST', 'COOKIE', 'GET', 'POST', 'FILES']; | |
if (php_sapi_name() !== 'cli') { |
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 | |
namespace Leads\Libraries; | |
class Datatables { | |
public static function ajax($table, Array $columns) | |
{ | |
/* | |
* Script: DataTables server-side script for PHP and MySQL |
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 | |
public function all() | |
{ | |
if (Request::ajax()) { | |
$encoded_html = gzencode(Model::all(), 9); | |
header('Content-Length: ' . strlen($encoded_html)); | |
header('Content-Encoding: gzip'); | |
return $encoded_html; | |
} |
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 | |
$log_file = 'lines.log'; | |
$read_start_position = 50; | |
$file = new SplFileObject($log_file); | |
$file->seek($read_start_position); | |
while(!$file->eof()) { |
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 count(*) tables, | |
concat(round(sum(table_rows)/1000000,2),'M') rows, | |
concat(round(sum(data_length)/(1024*1024*1024),2),'G') data, | |
concat(round(sum(index_length)/(1024*1024*1024),2),'G') idx, | |
concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G') total_size, | |
round(sum(index_length)/sum(data_length),2) idxfrac | |
FROM information_schema.TABLES; | |
+--------+----------+---------+--------+------------+---------+ | |
| tables | rows | data | idx | total_size | idxfrac | | |
+--------+----------+---------+--------+------------+---------+ |