Skip to content

Instantly share code, notes, and snippets.

View johncongdon's full-sized avatar

John Congdon johncongdon

View GitHub Profile
@johncongdon
johncongdon / 0_reuse_code.js
Created February 28, 2014 22:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Create Composer file and add MeetUp API PAckage
composer init --require="dms/meetup-api-client:~1.0"
# Install packages
composer install

Keybase proof

I hereby claim:

  • I am johncongdon on github.
  • I am johncongdon (https://keybase.io/johncongdon) on keybase.
  • I have a public key whose fingerprint is DFA0 91D5 A19F 1C10 4D4D 067C AD91 5449 071F 6AF3

To claim this, I am signing this object:

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)....");
}
public function __construct()
{
throw new Exception("You fucking know better than that! DO NOT INSTANTIATE ME!!!");
}
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']);
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
@johncongdon
johncongdon / ShowRequiredFields.php
Created February 23, 2012 21:25
Valid Required Fields
<?php
/**
* Changed based on feedback from rdohms
*/
$requiredFields = array(
'price',
'name',
'description',
'type',
'shippingCost',
@johncongdon
johncongdon / set_page_in_mysql.php
Created March 2, 2012 14:53
Storing data for general log
<?php
/*
* Set the current page name in a mysql variable
*
* This will be useful when the general_log is turned on and
* you want to drill down to a find out where these queries are running.
*/
$page = mysql_real_escape_string($_SERVER['REQUEST_URI']);
mysql_query("SET @page='$page'");
@johncongdon
johncongdon / gist:1986540
Created March 6, 2012 14:24
Does this caching scheme make sense?
/* Purpose: To have a Dependency Injected cache (we can change caching source easily)
* Question: Does throwing if not in cache make sense? This allows me to store FALSE as a value.
*/
class blah {
public function removeCachedKey($key) { }
public function putIntoCache($key, $value, $expirationTime = 3600)
{
$cache = self::$cache;
if ($cache && method_exists($cache, 'set')) {