Skip to content

Instantly share code, notes, and snippets.

@jburns131
jburns131 / My Custom Eclipse PDT PHP Editor Templates.md
Last active August 29, 2015 14:03
Eclipse PHP Editor DebuggingTemplates - Quick and easy code blocks that help speed up debugging time

Front Matter

Last tested using Eclipse 4.3.2 (Kepler), PDT v3.3.0

Explanation

Eclipse PDT's 'PHP Editor Templates' allow us to create custom autocompletion templates.

This is a small collection of templates I have created for personal use. These templates create code blocks that allow me to:

<?php
class CurrentUser
{
public $sessionId;
private $id;
private $loggedIn = false;
private $displayName;
private $sessionPersistent;
<?php
/**
* Create random salt for blowfish crypt hash
*/
$acmsSalt = sprintf('$2y$%02d$', 12).substr(str_replace('+', '.', base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(), mt_rand()))), 0, 22).'$';
<?php
...
public function loginAttempt()
{
$sql = new Db();
$form_helper = new FormHelper($this->basePath);
<?php
...
public function logoutAttempt()
{
$sql = new Db();
$this->sessionAxis->start();
#Naming Conventions
**Retrieval**
get(Descriptor) = Retrieve element(s), descriptor is optional
getOne = Retrieve single element
getSet = Retrieve a defined collection of elements
getAll = Retrieve all elements
@jburns131
jburns131 / phpdoc.bat
Last active December 21, 2015 03:58
phpdoc.bat
@ECHO OFF
php "%~dp0phpDocumentor.phar" %*
PAUSE
@jburns131
jburns131 / gist:6217218
Created August 13, 2013 02:11
Proposed Interface for phprbac

Proposed Interface:

  • Offer Two Interfaces:

    • All in one

        use PhpRbac\Rbac;
        
        $rbac = new Rbac; // Equals original jb::$RBAC object structure
      
@jburns131
jburns131 / gist:6216881
Last active December 20, 2015 23:59
My understanding of the public interface of phprbac...
  • Base Methods

    • jf::$RBAC->Assign($Role, $Permission)

    • jf::$RBAC->Check($Permission, $UserID)

    • jf::$RBAC->Enforce($Permission)

    • jf::$RBAC->Reset($Ensure=false)

@jburns131
jburns131 / gist:6202734
Created August 11, 2013 00:03
chmod folder
<?php
file_put_contents($dbConnFile, $data);
$currentOS = strtoupper(substr(PHP_OS, 0, 3));
if ($currentOS != 'WIN') {
chmod(DBCONNFILE, 0644);
}