Skip to content

Instantly share code, notes, and snippets.

View PHLAK's full-sized avatar
Coffee... always coffee...

Chris Kankiewicz PHLAK

Coffee... always coffee...
View GitHub Profile
@PHLAK
PHLAK / BttF.php
Created March 27, 2012 19:25
Back to the Future as code.
<?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 ) {
@PHLAK
PHLAK / .Xmodmap
Created October 25, 2012 19:22
Xmodmod key map for fixing Mac Pro keyboard
! 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
@PHLAK
PHLAK / archive-screenshots.sh
Created February 16, 2013 19:38
Screenshot archiving script.
#!/bin/bash
DAYS=5
# Calculate the threshold value
THRESHOLD=$(($DAYS * 24 * 60 * 60))
# Set current time
TIMESTAMP=$(date +%s)
@PHLAK
PHLAK / listRepos.php
Last active December 15, 2015 10:49
PHP-CLI script to output a list of repositories (one per line) belonging to the user(s) specified.
#!/usr/bin/php -q
<?php
// Disable errors
error_reporting(0);
foreach ($argv as $user) {
if ($user !== $argv[0]) {
@PHLAK
PHLAK / Singleton.php
Last active December 16, 2015 08:28
Example PHP singleton class for reference. For the record, singletons are evil: http://stackoverflow.com/a/138012/27025
<?php
/**
* Example PHP singleton class for reference.
* For the record, singletons are evil:
* http://stackoverflow.com/a/138012/27025
*/
class Singleton {
/**
@PHLAK
PHLAK / regex.php
Created April 19, 2013 19:37
Regex Testing
<?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();
@PHLAK
PHLAK / reflectionTesting.php
Created April 24, 2013 23:15
Testing out PHP's reflection functionality.
<?php
function doSomeShit($foo, $bar, $baz) {
// Do some shit...
}
$function = new ReflectionFunction('doSomeShit');
foreach ($function->getParameters() as $parameter) {
@PHLAK
PHLAK / example.conf
Last active December 25, 2015 19:19
UberGallery Nginx server config example
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;
}
@PHLAK
PHLAK / test.php
Created September 19, 2016 20:40
Testing the difference between PHP's "??" and "?:" operators.
<?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'
@PHLAK
PHLAK / .php_cs.dist
Last active May 16, 2017 03:14
Custom .php_cs.dist file for php-cs-fixer
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules([
'@PSR1' => true,
'@PSR2' => true,