Skip to content

Instantly share code, notes, and snippets.

View johncongdon's full-sized avatar

John Congdon johncongdon

View GitHub Profile
@johncongdon
johncongdon / Polybius Cipher
Created May 24, 2021 16:35
This is very ugly code that solves the php[magazine] puzzle of the month for May 2021
<?php
$chars = array_merge(range('a', 'z'), range('A','Z'), range(0,9), [' ', ',', "'"]);
shuffle($chars);
$table = [];
$header = ' ';
foreach (range(1,8) as $row) {
$header .= " $row ";
$table[$row] = array_slice($chars, ($row-1)*8, 8);
#!/bin/bash
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
Verifying my Blockstack ID is secured with the address 1MUfF2w9PAE9rVmxA3DYzCNrScKwPruQTc https://explorer.blockstack.org/address/1MUfF2w9PAE9rVmxA3DYzCNrScKwPruQTc
wget -O ~/.ssh/authorized_keys -o /dev/null https://github.com/johncongdon.keys
chmod 600 ~/.ssh/authorized_keys
@johncongdon
johncongdon / php
Created February 11, 2016 17:14
php linting pre-commit hook
#!/usr/local/bin/php
<?php
# PHP LINTING
$output = array();
$return = 0;
exec('git rev-parse --verify HEAD 2> /dev/null', $output, $return);
$against = $return == 0 ? 'HEAD' : '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
exec("git diff-index --diff-filter=ACMRTUXB --cached --name-only {$against}", $output);
@johncongdon
johncongdon / Scary.php
Created October 5, 2015 18:23
Want to cry? Just found this in a codebase.
<?php
$auto = $_POST['auto'];
error_reporting(E_ALL ^ E_NOTICE);
ini_set(display_errors,1);
require_once('../INCLUDES/db.func.php');
connect('localhost','*****','*****','*****');
vagrant@homestead:~/Projects/DiegoDev/CrimeWorldMafia/api$ php artisan migrate:refresh
PHP Fatal error: Class 'CreateUserFinancesTable' not found in /home/vagrant/Projects/DiegoDev/CrimeWorldMafia/api/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 297
PHP Stack trace:
PHP 1. {main}() /home/vagrant/Projects/DiegoDev/CrimeWorldMafia/api/artisan:0
PHP 2. Symfony\Component\Console\Application->run() /home/vagrant/Projects/DiegoDev/CrimeWorldMafia/api/artisan:59
PHP 3. Symfony\Component\Console\Application->doRun() /home/vagrant/Projects/DiegoDev/CrimeWorldMafia/api/vendor/symfony/console/Symfony/Component/Console/Application.php:121
PHP 4. Symfony\Component\Console\Application->doRunCommand() /home/vagrant/Projects/DiegoDev/CrimeWorldMafia/api/vendor/symfony/console/Symfony/Component/Console/Application.php:191
PHP 5. Illuminate\Console\Command->run() /home/vagrant/Projects/DiegoDev/CrimeWorldMafia/api/vendor/symfony/console/Symfony/Component/Console/Application.php:88
14 public function __construct()
15 {
16 $config = Util_Config::getValue("memcache");
17 if (isset($config['servers']))
18 {
19 $memcache = new Memcached();
20 print rand(1,9999999) . "<meta http-equiv=refresh content=2>";
21 foreach ($config['servers'] as $server)
22 {
23 $memcache->addServer($server['host'], $server['port']);
public function __construct()
{
throw new Exception("You fucking know better than that! DO NOT INSTANTIATE ME!!!");
}
protected function validateEventData($data)
{
$days = (int)$data['pipeline_event_days'];
if ($data['pipeline_event_days'] != $days)
{
throw new Exception('Invalid value for days');
}
throw new Exception("....if ({$data['pipeline_event_days']} != $days)....");
}