Skip to content

Instantly share code, notes, and snippets.

@julienhay
julienhay / gist:8333892
Last active January 2, 2016 16:59
Delete directory PHP function
<?php
function deleteDirectory($dirname, $delete_self = true)
{
$dirname = rtrim($dirname, '/').'/';
if ($files = scandir($dirname))
{
foreach ($files as $file)
if ($file != '.' && $file != '..' && $file != '.svn')
{
@julienhay
julienhay / gist:8334125
Last active January 2, 2016 16:59
Fonction Import csv (à adapter)
<?php
function importCSV() {
ini_set('auto_detect_line_endings',TRUE);
if ($this->request->is('post')) {
$dataToSave = array();
$row = 1;
if($this->data['Contacts']['csv_file']['type'] == "text/csv")
@julienhay
julienhay / gist:8349081
Created January 10, 2014 09:30
Exemple de livraison auto avec capistrano pour prestashop (à tester)
set :application, "xxx"
set :repository, "git@github.com:Pajk/prestashop.git"
set :scm, :git
role :web, "1.1.1.1"
role :app, "1.1.1.1"
role :db, "1.1.1.1", :primary => true
role :db, "1.1.1.1"
$config = {
"application" => "DOMAIN.TLD",
"repository" => "git@GITHOST:USERNAME/REPOSITORYNAME.git",
"remoteusername" => "REMOTEUSERNAME",
"cake_folder" => "/PATH/TO/CAKE",
"cake_version" => "cakephp1.3",
"plugin_dir" => "plugins",
"servers" => {
"prod" => {
"server" => "APPLICATION.TLD",
@julienhay
julienhay / gist:8439423
Created January 15, 2014 16:31
Bash ffmpeg génère tous les formats web et 3 vignettes
#!/bin/bash
ffmpeg -i $1 -vcodec libx264 -b 200k -vf scale=iw/2:-1 video.mp4
ffmpeg -i video.mp4 -vcodec libtheora video.ogv
ffmpeg -i video.mp4 -b 700k video.webm
ffmpeg -i video.mp4 -vcodec flv video.flv
ffmpeg -itsoffset -1 -i video.mp4 -vframes 1 -filter:v scale="400:-1" thumb1.png
ffmpeg -itsoffset -5 -i video.mp4 -vframes 1 -filter:v scale="400:-1" thumb2.png
@julienhay
julienhay / gist:8544677
Last active January 4, 2016 00:49
Method to get thumbnail from url for Youtube/Vimeo
<?php
private function video_thumbnail_url($url)
{
if(!filter_var($url, FILTER_VALIDATE_URL)){
// URL is Not valid
return false;
}
$domain=parse_url($url,PHP_URL_HOST);
$url_dec=parse_url($url);
@julienhay
julienhay / default.ctp
Last active March 10, 2018 23:59
CakePHP default template with, jquery, jquery UI & bootsrap (CDN)
<!DOCTYPE html>
<html>
<head>
<?php echo $this->Html->charset(); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
<?php
if($this->fetch('title')):
@julienhay
julienhay / index.html
Last active September 26, 2018 14:04
Base template, jquery, jquery UI, bootstrap (CDN)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css" />
@julienhay
julienhay / Redim-auto.jsx
Created February 20, 2014 17:24
Script Photoshop resize image (Portrait and Landscape auto) 1024x -> And generate miniature
// get a reference to the current (active) document and store it in a variable named "doc"
doc = app.activeDocument;
var fWidthBig = 1024;
doc.resizeImage(UnitValue(fWidthBig,"px"),null,null,ResampleMethod.BICUBIC);
var options = new ExportOptionsSaveForWeb();
options.quality = 70;
@julienhay
julienhay / base.html.twig
Last active April 9, 2024 15:38
Base Twig file with Jquery, Jquery UI & Bootstrap (CDN)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css" />