Skip to content

Instantly share code, notes, and snippets.

||msftncsi.com^
||*watson*
||*telemetry*
||w.tools^
||windows.com^
||*.sk^
||trafficmanager.net^
||cloudapp.net^
@GerrSwin
GerrSwin / sql
Created January 24, 2017 12:25
MySQL Nested Set Model
CREATE PROCEDURE `tree_create`() MODIFIES SQL DATA
BEGIN
DECLARE currentId, currentParentId CHAR(36);
DECLARE currentLeft INT;
DECLARE startId INT DEFAULT 1;
SET max_heap_table_size = 1024 * 1024 * 512;
START TRANSACTION;
@GerrSwin
GerrSwin / php
Created June 9, 2016 06:40
cli colors
<?php
echo cliColor::convert('test', 'red'), "\n";
class cliColor {
static private $instance;
static private $font = [
'black' => '0;30',
@GerrSwin
GerrSwin / php
Created April 19, 2016 07:15
cli progressbar
function progressBar($done, $total)
{
$perc = floor(($done / $total) * 100);
$left = 100 - $perc;
fwrite(STDERR, sprintf("\033[0G\033[2K[%'#{$perc}s%-{$left}s] - $perc%% - $done/$total", "", ""));
}
@GerrSwin
GerrSwin / tpl php
Last active February 27, 2016 21:43
pagination
<nav>
<ul class="pagination">
<li <? if ($page == 1) echo 'class="disabled"' ?>>
<a href="<?= ($page == 1 ? '' : $page - 1) ?>" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
</li>
<?
$links = 10;
$start = ($page - $links) > 0 ? $page - $links : 1;
$end = ($page + $links) < $totalPages ? $page + $links : $totalPages;