Skip to content

Instantly share code, notes, and snippets.

Michaël Marinetti Asenar

Block or report user

Report or block Asenar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cereal-s
cereal-s / ping.gs.php
Created Sep 8, 2017
Get number of pages from a PDF, using GhostScript.
View ping.gs.php
<?php
/**
* Return the number of pages of a PDF.
*
* Imagick::pingImage() takes too much when dealing with big files.
*
* Command to execute:
*
* gs -q -dNODISPLAY -c "(%s) (r) file runpdfbegin pdfpagecount = quit"
@Seldaek
Seldaek / bench.php
Created Dec 8, 2015
strtr vs str_replace benchmark
View bench.php
<?php
$jobs = array(
'old/strtr' => function($args) {
$classes = [];
foreach ($args as $class) {
$classes[] = strtr($class, '\\', DIRECTORY_SEPARATOR);
}
return $classes;
},
@lumpysimon
lumpysimon / wp-disable-rest.php
Created Nov 26, 2015
Completely disable WordPress REST API
View wp-disable-rest.php
add_filter( 'rest_enabled', '_return_false' );
add_filter( 'rest_jsonp_enabled', '_return_false' );
@maxgalbu
maxgalbu / Switch_Node.php
Last active Dec 31, 2019
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
View Switch_Node.php
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
@suzuki
suzuki / mail2.php
Created Feb 2, 2014
Swift Mailer sample / DKIM email
View mail2.php
<?php
require 'vendor/autoload.php';
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
$mailer = Swift_Mailer::newInstance($transport);
// DKIM 用の Signer を作成する
$privateKey = file_get_contents('./default.private');
$domainName = 'example.com';
@leylaso
leylaso / pad.js
Created Mar 28, 2012
custom pad.js file for etherpad-lite allows setting author names as line numbers
View pad.js
/**
* @file
* This file is an example of ways to modify etherpad-lite behaviour from the
* static/custom/pad.js file generated by etherpad-lite on first run.
*/
var edBod = [];
var lastLine = 0;
/**
@spulec
spulec / pre-commit
Last active Nov 26, 2019
Yipit Pre-commit Hook
View pre-commit
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^[MA]\s+(?P<name>.*)$')
CHECKS = [
View gist:519251
# GIT PS1
# COLORS
LIGHT_GRAY="\[\033[0;37m\]"; BLUE="\[\033[0;34m\]"; RED="\[\033[0;31m\]"; LIGHT_RED="\[\033[1;31m\]";
GREEN="\[\033[0;32m\]"; WHITE="\[\033[1;37m\]"; LIGHT_GRAY="\[\033[0;37m\]"; YELLOW="\[\033[1;33m\]";
BROWN="\[\033[0;33m\]"; BLACK="\[\033[0;30m\]";PURPLE="\[\033[0;35m\]";CYAN="\[\033[0;36m\]";
# GIT PROMPT (http://gist.github.com/120804)
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/';
}
function parse_git_status {
You can’t perform that action at this time.