Skip to content

Instantly share code, notes, and snippets.

View lorenzo's full-sized avatar

José Lorenzo Rodríguez lorenzo

View GitHub Profile
@lorenzo
lorenzo / Counter.elm
Last active September 21, 2016 15:07 — forked from hipertracker/Counter.elm
Elm example
module Main exposing (..)
{- This file re-implements the Elm Counter example (1 counter) with elm-mdl
buttons. Use this as a starting point for using elm-mdl components in your own
app.
-}
import Html.App as App
import Html exposing (..)
import Html.Attributes exposing (href, class, style)
<?php
if (!empty($this->request->data('applications.companies_ids'))) {
// Recupero gli ids delle aziende a cui l'agente si è candidato
$companiesIds = array_diff(
$this->request->data('applications.companies_ids'),
(new Collection($agent->applications))->extract('company_id')->toArray()
);
@lorenzo
lorenzo / fill.ctp
Created November 24, 2015 09:26 — forked from mnithya/fill.ctp
<div class="container">
<div class="form-group">
<?= $this->Form->create($assessmentForm) ?>
<fieldset>
<legend><?= __($assessmentForm->title) ?></legend>
<?php foreach ($questions as $k => $question): ?>
<?php echo $this->Form->hidden("$k.qid", ['value'=> $question->qid]) ?>
<?php echo $this->Form->input("$k.answer_text", ['label' => $question['text']]) ?>
<?php endforeach; ?>
</fieldset>
Table
public function validationDefault(Validator $validator)
{
$validator
->requirePresence('device_id', 'create')
->notEmpty('device_id');
return $validator;
}
@lorenzo
lorenzo / gist:210fc430a0afe6469fc2
Last active September 19, 2015 12:49 — forked from fly2279/gist:4edee4cb14e35c133806
Query with belongsToMany and belongsTo association
<?php
$query = $this->Articles->find('all')
->leftJoinWith('ArticlesAuthors')
->leftJoinWith('Authors')
->where(['Authors.id' => 1])
->orWhere(['ArticlesAuthors.author_id' => 1]);
@lorenzo
lorenzo / 0_reuse_code.js
Last active August 29, 2015 14:21
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
<?php
use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::defaultRouteClass('Route');
$languageCodes = array('fr_FR', 'pt_BR');
$builder = function ($routes) {
$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
class AppController extends Controller {
public $components = array(
'Session',
'Cookie',
'Auth' => array(
'authenticate' => array(
'Form' => array(
'userModel' => 'Member',
'fields' => array('username' => 'pseudo', 'password' => 'password')
)
@lorenzo
lorenzo / routes.php
Last active August 29, 2015 14:02 — forked from archanavhire/routes.php
Capitalizing controller names
<?php
/**
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)