Skip to content

Instantly share code, notes, and snippets.

Avatar
🌵
Working Remotely

Paul Giberson aknosis

🌵
Working Remotely
View GitHub Profile
@aknosis
aknosis / test.yml
Created Aug 27, 2019
PHPUnit / Laravel GitHub Action
View test.yml
name: Test
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
View zendcon-2014-suchtweets.md

#Me

  • Paul Giberson
  • Applications Architect @ Socious [socious.com]
  • PHP for 6 years, "PHP" for 3 years prior

##Idea

  • Appeal to attendees = twitter
  • Word cloud of #zendcon (graphical representations of data are awesome)
@aknosis
aknosis / calendar.twig
Created Oct 22, 2012
Table based calendar only using Twig
View calendar.twig
{#
time can be any string acceptable by http://www.php.net/strtotime, the
template will output that time's month.
If you don't want to pass in a date you can set time like this:
{% set time = "now"|date("U") %}
{% set time = "December 2012"|date("U") %}
How ever you want to output items onto the calendar is a different issue,
but I'd assume pushing everything into an array numerically indexed by that day:
@aknosis
aknosis / gist:2347191
Created Apr 9, 2012
TIL - How to use rawurlencode instead of urlencode with Twig
View gist:2347191
{# varaible is 'Hello There' #}
{{ variable|url_encode() }} {# Hello+There #}
{# If you want to use rawurlencode what do you do? #}
{{ variable|url_encode(true) }} {# Hello%20There #}
@aknosis
aknosis / prompt.php
Created Jan 18, 2012
Read from stdin to a php variable
View prompt.php
<?php
/**
* Usage:
* $answer = prompt("What is your quest?");
* echo "Answer: $answer";
*
* Outputs:
* What is your quest?
* I seek the holy grail!
* Answer: I seek the holy grail!
@aknosis
aknosis / gist:1323675
Created Oct 28, 2011
Conditional inside WHERE clause
View gist:1323675
-- Example of how to include an if conditional in a where clause
-- We only want rows where a = 1 or 2 but only a = 2 if b = 4
-- table structure:
-- [ a | b ]
-- 1 4
-- 2 4
-- 1 5
-- 3 9
-- 2 7
@aknosis
aknosis / cache.php
Created Sep 2, 2011
Simple File Based Cache Mechanism in PHP
View cache.php
<?php
/**
* @param string $uniqID - Anything that would be unique to what you are caching (url/database query)
* @param integer $expireSeconds - How old is too old that we refresh the cache
*/
function _getFromCache($uniqID,$expireSeconds){
$uniq = '/<path to your cache storage folder>/'.md5($uniqID);
if(file_exists($uniq) && time() - filemtime($uniq) <= $expireSeconds){
return '<process cached file>($uniq)';
}
@aknosis
aknosis / gist:1079084
Created Jul 12, 2011
Random string in unix
View gist:1079084
echo `</dev/urandom tr -dc A-Za-z0-9 | head -c8`
@aknosis
aknosis / gist:1054257
Created Jun 29, 2011
Check if a class constant exists in PHP
View gist:1054257
<?php
if(defined('className::CONSTANT_NAME')){
//defined
}else{
//not defined
}
@aknosis
aknosis / wtf.php
Created Jun 24, 2011
You have to love php...
View wtf.php
<?php
"string" == 0; //true
"string" === 0; //false