Skip to content

Instantly share code, notes, and snippets.

@julienhay
julienhay / deploy.rb
Created April 8, 2014 16:16
Deploy Cakephp Capistrano 3
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'YourJouney'
set :repo_url, '[email protected]:yourjourney.git'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
@julienhay
julienhay / index.php
Created April 11, 2014 10:11
first end in foreach PHP
<?php
foreach($array as $element) {
if ($element === reset($array))
echo 'FIRST ELEMENT!';
if ($element === end($array))
echo 'LAST ELEMENT!';
}
@julienhay
julienhay / AppController.php
Created April 14, 2014 14:34
Action upload Cakephp (to adapt)
<?php
public function video($fiche_id = null)
{
$this->breadcrumb[] = array(
'text' => __('Gestion vidéo')
);
$zone_id = $this->request->params['named']['zone'];
@julienhay
julienhay / AppController.php
Created May 7, 2014 13:46
Auth Init Cakephp
class AppController extends Controller {
public $components = array(
'Auth',
'Session',
);
@julienhay
julienhay / ExampleController.php
Last active August 29, 2015 14:01
Upload files example Cakephp + CRUD
<?php
App::uses('AppController', 'Controller');
App::uses('Folder', 'Utility');
App::uses('File', 'Utility');
App::uses('CakeTime', 'Utility');
class ExampleController extends AppController {
public static $accept_types = array(
<?php
App::uses('AppController', 'Controller');
App::uses('Folder', 'Utility');
App::uses('File', 'Utility');
App::uses('CakeTime', 'Utility');
class ExempleController extends AppController {
public function implementedEvents()
{
@julienhay
julienhay / CustomTwigExtension.php
Created September 22, 2014 15:05
Twig filter beautiful slice
<?php
namespace ES\SamsungCSBundle\Twig;
class CustomTwigExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
new \Twig_SimpleFilter('slice_beautiful', array($this, 'beautifulTruncate')),
@julienhay
julienhay / mediamixin
Created September 23, 2014 08:33 — forked from remyzv/mediamixin
@mixin media($point) {
@if $point == mobile {
@media screen and (max-width : em(768)) { @content ; }
}
@else if $point == tablet {
@media screen and (max-width : em(992)) and (min-width: em(768)) { @content ; }
}
@else if $point == laptop {
@media screen and (max-width : em(1200)) and (min-width: em(992)) { @content ; }
}
@julienhay
julienhay / tmux_loader.sh
Last active August 29, 2015 14:07
Tmux Loader
#!/bin/bash
SESSIONNAME="work"
tmux has-session -t $SESSIONNAME > /dev/null
if [ $? != 0 ]
then
tmux new-session -s $SESSIONNAME -n "vagrant" -d
tmux new-window -t $SESSIONNAME:1 -n "vserver"
@julienhay
julienhay / getpostsbylang.php
Created October 23, 2014 08:40
Get posts by lang WPML
<?php
function get_posts_by_lang($args = array(), $lang = "fr") {
global $wpdb;
$post_table = $wpdb->posts;
$translation_table = $wpdb->prefix . 'icl_translations';
$sql = "
SELECT ID