Skip to content

Instantly share code, notes, and snippets.

View jmcollin's full-sized avatar

Jean-Marie Collin jmcollin

View GitHub Profile
@jmcollin
jmcollin / curlGetHTTPCode.php
Last active March 3, 2021 18:50
PHP: Get http code from a Curl request
<?php
function curlGetHTTPCode($url)
{
if (function_exists('curl_init'))
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
@jmcollin
jmcollin / gitArchive.php
Last active August 29, 2015 14:22
PHP: Display git command to zip in a subfolder in a git repository
<?php
function gitArchive($path)
{
if (is_dir($path))
{
$dir = new DirectoryIterator($path);
foreach ($dir as $fileInfo)
{
if($fileInfo->isDot() || $fileInfo->getFilename()[0] == '.')
continue;
@jmcollin
jmcollin / optimizePNG.sh
Created June 4, 2015 16:09
Shell: Optimize PNG images (pngquant & pngcrush)
#!/bin/bash
# Create tree path
function mymv ()
{
dir="$2"
tmp="$2"; tmp="${tmp: -1}"
[ "$tmp" != "/" ] && dir="$(dirname "$2")"
[ ! -a "$dir" ] &&
mkdir -p "$dir" &&
@jmcollin
jmcollin / optimizeGIF.sh
Created June 4, 2015 16:41
Shell: Optimize gif images (gifsicle)
#!/bin/bash
# Create tree path
function mymv ()
{
dir="$2"
tmp="$2"; tmp="${tmp: -1}"
[ "$tmp" != "/" ] && dir="$(dirname "$2")"
[ ! -a "$dir" ] &&
mkdir -p "$dir" &&
@jmcollin
jmcollin / scan
Created July 13, 2015 08:07
Search for SQL queries in a PrestaShop Module
grep -R --color -n -A 10 -B 10 'Db::getInstance'
@jmcollin
jmcollin / mozjpeg.sh
Last active August 29, 2015 14:25
Compilation mozjpeg
git clone https://github.com/mozilla/mozjpeg.git
cd mozjpeg
autoreconf -fiv
mkdir build
cd build
sh ../configure
make install
@jmcollin
jmcollin / pngquant.sh
Created July 26, 2015 09:26
Compilation pngquant
git clone https://github.com/pornel/pngquant.git
cd pngquant
./configure
make
make install
@jmcollin
jmcollin / pngcrush.sh
Last active August 29, 2015 14:25
Compilation pngcrush​
wget http://skylink.dl.sourceforge.net/project/pmt/pngcrush/1.7.86/pngcrush-1.7.86.zip
unzip pngcrush-1.7.86.zip && cd pcr010786/
make
whereis pngcrush
cp -f pngcrush /usr/bin/pngcrush
cp -f pngcrush /usr/bin/X11/pngcrush
@jmcollin
jmcollin / twig.php
Created August 4, 2015 07:40
Twig get template name
$filter = new Twig_SimpleFilter('myFunction', function (Twig_Environment $env, $param) use ($twig) {
echo $twig->getCompiler()->getFilename();
}, array('needs_environment' => true));
$twig->addFilter($filter);
@jmcollin
jmcollin / gifsicle.sh
Last active August 29, 2015 14:26
Compilation gifsicle​
git clone https://github.com/kohler/gifsicle.git
cd gifsicle/
./bootstrap.sh
./configure
make
make install