This gist is about:
- https://twitter.com/taylorotwell/status/600680897550098432
- https://twitter.com/Ocramius/status/600705252539691008
Mainly:
functioncannot (should not) be used when side-effects occur
| <?php | |
| function mb_substr_replace($string, $replacement, $start, $length=NULL) { | |
| if (is_array($string)) { | |
| $num = count($string); | |
| // $replacement | |
| $replacement = is_array($replacement) ? array_slice($replacement, 0, $num) : array_pad(array($replacement), $num, $replacement); | |
| // $start | |
| if (is_array($start)) { | |
| $start = array_slice($start, 0, $num); | |
| foreach ($start as $key => $value) |
| *[class]:before { | |
| position: absolute; | |
| background: rgba(10,10,10,.6); | |
| padding: 10px; | |
| border-radius: 4px; | |
| color: white; | |
| font-size: 10px; | |
| display: block; | |
| content: "[" attr(class) "] " ; | |
| } |
| <?php | |
| class ColorCLI { | |
| static $foreground_colors = array( | |
| 'bold' => '1', 'dim' => '2', | |
| 'black' => '0;30', 'dark_gray' => '1;30', | |
| 'blue' => '0;34', 'light_blue' => '1;34', | |
| 'green' => '0;32', 'light_green' => '1;32', | |
| 'cyan' => '0;36', 'light_cyan' => '1;36', |
| -- select all query -- | |
| SELECT b.bookTitle, a.authorName FROM book b | |
| INNER JOIN author_book ab ON ab.bookID = b.bookID | |
| INNER JOIN author a ON a.authorID = ab.authorID | |
| ORDER BY b.bookTitle | |
| -- select all with authors concantenated -- | |
| SELECT b.bookTitle, GROUP_CONCAT(a.authorName) authors FROM book b |
| <?php namespace Octopus; | |
| use \Closure; | |
| class MiddlewareComposer | |
| { | |
| protected $pipe; | |
| protected $context; | |
| protected $errorHandler; | |
| protected $successHandler; |
| <?php | |
| // original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/ | |
| /* | |
| The MIT License (MIT) | |
| Copyright (c) 2015 | |
| Permission is hereby granted, free of charge, to any person obtaining a copy |
| @echo off | |
| SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe | |
| rem add it for all file types | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f | |
| rem add it for folders | |
| @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f |
| A list of Sublime Text 3 scopes to be used for Snippets Makers / Plugin Developers. | |
| Main Symbol Scopes: entity.name.function, entity.name.type, meta.toc-list | |
| ActionScript: source.actionscript.2 | |
| AppleScript: source.applescript | |
| ASP: source.asp | |
| Batch FIle: source.dosbatch | |
| BibTex: source.bibtex | |
| C#: source.cs |
| <?php | |
| /* Found at http://stackoverflow.com/questions/1057572/how-can-i-get-a-hex-dump-of-a-string-in-php */ | |
| function hex_dump($data, $newline="\n") | |
| { | |
| static $from = ''; | |
| static $to = ''; | |
| static $width = 16; # number of bytes per line |
This gist is about:
Mainly:
function cannot (should not) be used when side-effects occur