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 | |
class User { | |
public int $id; | |
public string $name; | |
public function __construct(int $id, string $name) { | |
$this->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
<?php | |
class User { | |
/** @var int $id */ | |
private $id; | |
/** @var string $name */ | |
private $name; | |
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 | |
use Money\Currencies\ISOCurrencies; | |
use Money\Parser\DecimalMoneyParser; | |
use Money\Formatter\IntlMoneyFormatter; | |
use Money\Converter; | |
use Money\Currency; | |
use Money\Exchange\FixedExchange; | |
use Money\Exchange\ReversedCurrenciesExchange; |
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 App\Providers; | |
use Illuminate\Support\Collection; | |
use Illuminate\Pagination\LengthAwarePaginator; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
public function boot() |
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 | |
print "<h1>PHP Encryption with libsodium</h1>"; | |
$message = "This text is secret"; | |
$ciphertext = cryptor::encrypt("password", $message); | |
$plaintext = cryptor::decrypt("password", $ciphertext); | |
print "Message:<br />$message <br /><br />Ciphertext:<br />$ciphertext<br /><br />Plaintext:<br />$plaintext"; |
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
Resources marked with > are used, have been used, or are actively advocated in the threads. This applies for everything in the [Necessities] section. | |
[Necessities] | |
Hiragana & Katakana: http://www.realkana.com/ | |
Kanji: http://kanjidamage.com/ | |
Japanese IME: http://www.google.com/intl/ja/ime/ | |
Anki Flashcards: http://ankisrs.net/ | |
Genki (↓Bottom↓) | |
Tae Kim Japanese: http://www.guidetojapanese.org/learn/grammar |
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
function makeNested($source) { | |
$nested = array(); | |
foreach ( $source as &$s ) { | |
if ( is_null($s['parent_id']) ) { | |
// no parent_id so we put it in the root of the array | |
$nested[] = &$s; | |
} | |
else { | |
$pid = $s['parent_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
// https://stackoverflow.com/a/33259643 | |
function get_combinations($arrays) { | |
$result = array(array()); | |
foreach ($arrays as $property => $property_values) { | |
$tmp = array(); | |
foreach ($result as $result_item) { | |
foreach ($property_values as $property_key => $property_value) { | |
$tmp[] = $result_item + array($property_key => $property_value); | |
} |
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 | |
function array_to_tree(array $array, $parent_id = 0) | |
{ | |
$array = array_combine(array_column($array, 'id'), array_values($array)); | |
foreach ($array as $k => &$v) { | |
if (isset($array[$v['parent_id']])) { | |
$array[$v['parent_id']]['children'][$k] = &$v; | |
} |
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
function hex2rgb($hex) { | |
$hex = str_replace("#", "", $hex); | |
if(strlen($hex) == 3) { | |
$r = hexdec(substr($hex,0,1).substr($hex,0,1)); | |
$g = hexdec(substr($hex,1,1).substr($hex,1,1)); | |
$b = hexdec(substr($hex,2,1).substr($hex,2,1)); | |
} else { | |
$r = hexdec(substr($hex,0,2)); | |
$g = hexdec(substr($hex,2,2)); |