Skip to content

Instantly share code, notes, and snippets.

cgTag thinkingmedia

View GitHub Profile
@thinkingmedia
thinkingmedia / p4merge4git.md
Created Jun 15, 2017 — forked from tony4d/p4merge4git.md
Setup p4merge as a visual diff and merge tool for git
View p4merge4git.md
View gist:5a288e32b95dc78b54b26c9f170e7e07
class RestCreateComponent extends RestComponent
{
public $components = ['RestError'];
public function initialize(array $config)
{
parent::initialize($config);
$con = $this->getController();
$this->eventManager($con->eventManager());
}
public function create() {
@thinkingmedia
thinkingmedia / disposable.php
Last active Jan 13, 2017
Disposable pattern implemented in PHP
View disposable.php
<?php
/**
* Wraps the callable in a try/finally before calling dispose()
*
* @param GemsDisposable $obj
* @param callable $worker
* @return mixed
*/
function using(GemsDisposable $obj, callable $worker)
{
@thinkingmedia
thinkingmedia / GemsAssert.php
Created Nov 9, 2016
A handler for ORM read/write operations
View GemsAssert.php
<?php
namespace Gems\Tools;
use Cake\Datasource\EntityInterface;
use Cake\Error\PHP7ErrorException;
use Cake\Log\Log;
use Cake\ORM\Table;
use Cake\Utility\Hash;
use Error;
@thinkingmedia
thinkingmedia / gist:7dafb8e27ed999440038
Created Mar 29, 2016
Fix for registration and signed in.
View gist:7dafb8e27ed999440038
<?php
namespace App\Controller;
use CakeDC\Users\Controller\Traits\LoginTrait;
use CakeDC\Users\Controller\Traits\RegisterTrait;
class UsersController extends AppController {
use RegisterTrait {
@thinkingmedia
thinkingmedia / nano.cmd
Created Jan 18, 2016
An alias for Windows that lets you start NotePad++ when you type `nano filename.txt` on the command line.
View nano.cmd
@ECHO OFF
start notepad++ %*
@thinkingmedia
thinkingmedia / gitty.cmd
Created Jan 18, 2016
Type `gitty` in a Windows prompt to add, commit and push with one command.
View gitty.cmd
@ECHO OFF
git status
IF %ERRORLEVEL% NEQ 0 (EXIT /B -1)
git add --all
IF %ERRORLEVEL% NEQ 0 (EXIT /B -1)
IF "%~1"=="" GOTO END_BATCH
git commit -m %1
IF %ERRORLEVEL% NEQ 0 (GOTO END_BATCH)
@thinkingmedia
thinkingmedia / q.cmd
Created Jan 18, 2016
Type `g` on the Windows command to show details about the current working directory in Git.
View q.cmd
@ECHO OFF
git remote -v
git status
git branch
View gist:8b85f275f48ac22814e9
public function saveKeyValues(Model $Model, $data){
if(empty($data) || !isset($data[$Model->alias]) || empty($data[$Model->alias]))
{
return false;
}
$optionKey = $this->options[$Model->alias]['fields']['key'];
$optionValue = $this->options[$Model->alias]['fields']['value'];
// I don't understand this part.
View gist:210072f01d6235c57174
public boolean isPrime(int n)
{
int divisor = 2;
int limit = n-1 ;
if (n == 2)
{
return true;
}
You can’t perform that action at this time.