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 | |
$date = date('M d, Y - h:i A', 499155600); // Oct 26, 1985 - 01:20 AM | |
$libyans = false; | |
$speed = 0; | |
$watts = 1210000000; | |
while ($libyans == true) { | |
if ($speed >= 88 && $watts == 1210000000 ) { |
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
! Set key codes | |
keycode 37 = Control_L | |
keycode 105 = Control_R | |
keycode 64 = Super_L | |
keycode 108 = Super_R | |
keycode 133 = Alt_L | |
keycode 134 = Alt_R | |
keycode 191 = Print | |
! Clear key modifier mappings |
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
#!/bin/bash | |
DAYS=5 | |
# Calculate the threshold value | |
THRESHOLD=$(($DAYS * 24 * 60 * 60)) | |
# Set current time | |
TIMESTAMP=$(date +%s) |
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
#!/usr/bin/php -q | |
<?php | |
// Disable errors | |
error_reporting(0); | |
foreach ($argv as $user) { | |
if ($user !== $argv[0]) { |
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 | |
/** | |
* Example PHP singleton class for reference. | |
* For the record, singletons are evil: | |
* http://stackoverflow.com/a/138012/27025 | |
*/ | |
class Singleton { | |
/** |
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 | |
// Read file contents to string | |
$doc = file_get_contents('secret-doc.txt'); | |
// Run the regex on the string | |
preg_match_all('/\(?[0-9]{3}\)?[- ]?[0-9]{3}[-\ ]?[0-9]{4}/', $doc, $matches); | |
// Print out an array of matches | |
print_r($matches); die(); |
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 doSomeShit($foo, $bar, $baz) { | |
// Do some shit... | |
} | |
$function = new ReflectionFunction('doSomeShit'); | |
foreach ($function->getParameters() as $parameter) { |
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
server { | |
root /var/www/example; | |
server_name example.com www.example.com; | |
location / { | |
index index.php index.html index.htm; | |
try_files $uri $uri/ /index.php; | |
} |
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 | |
unset($foo); | |
var_dump($foo ?? 'bar'); // 'bar' | |
var_dump($foo ?: 'bar'); // 'bar' (PHP Notice: Undefined variable: foo ...) | |
$foo = 'foo'; | |
var_dump($foo ?? 'bar'); // 'foo' | |
var_dump($foo ?: 'bar'); // 'foo' |
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 | |
$finder = PhpCsFixer\Finder::create() | |
->exclude('vendor') | |
->in(__DIR__); | |
return PhpCsFixer\Config::create() | |
->setRules([ | |
'@PSR1' => true, | |
'@PSR2' => true, |