Skip to content

Instantly share code, notes, and snippets.

View dakota's full-sized avatar

Walther Lalk dakota

View GitHub Profile
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "<Old Name>" ];
then
GIT_COMMITTER_NAME="<New Name>";
GIT_AUTHOR_NAME="<New Name>";
GIT_COMMITTER_EMAIL="<New Email>";
GIT_AUTHOR_EMAIL="<New Email>";
git commit-tree "$@";
else
git commit-tree "$@";
@dakota
dakota / app_model.php
Created December 15, 2011 10:37
DB agnostic virtual fields
<?php
class AppModel extends Model {
private $sqlMap = array(
'mysql' => array(
'now' => 'NOW()',
'if' => 'IF(%1$s,%2$s,%3$s)',
'concat' => array('CONCAT(%s)', 'implode', ','),
'hour' => 'HOUR',
'year' => 'YEAR',
'date_sub' => 'DATE_SUB(%1$s, INTERVAL %2$s %3$s)',
<div class="users index">
<h2><?php echo __('Users'); ?></h2>
<?php
echo "<table cellpadding='0' cellspacing='0'>
<tr>
<th>No</th>
<th>ID</th>
<th>Username</th>
<th>Role</th>
<th>Status</th>
<?php
namespace App\View;
use Cake\View\View;
/**
* Class HintView
*
* @property \Cake\View\Helper\FormHelper $Form
* @property \Cake\View\Helper\HtmlHelper $Html
<?php
//Add method
public function add() {
if ($this->request->is('post')) {
$this->Truck->create();
if ($this->Truck->saveAssociated($this->request->data)) {
$this->Session->setFlash(__('The truck has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The truck could not be saved. Please, try again.'));
<?php
$assets = array(
'0' => array(
'Asset' => array(
'id' => '542273cb-2490-490d-b771-4ec767094594',
'name' => 'Congregations (Dashboard)',
'alias' => 'Congregations/dashboard',
'modified' => ''
),
<?php
public function add() {
$applicant = $this->Applicants->newEntity($this->request->data);
debug($applicant);
$subjects = $this->Applicants->ApplicantSubjects->Subjects->find('list');
$this->set('subjects', $subjects);
$this->set('applicant', $applicant);
}
<?php
$validator
->allowEmpty('number')
->add('number', 'valid', [
'rule' => function ($value) {
return preg_match('/^(((\+44)? ?(\(0\))? ?)|(0))( ?[0-9]{3,4}){3}$/', $value) === 1;
}
]);
Router::scope('/users', ['controller' => 'Creators'], function (RouteBuilder $routes) {
$routes->connect('/add', ['action' => 'add']);
});
vagrant@VAGRANT-BOX ~
$ cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\vagrant>echo %cd%