Skip to content

Instantly share code, notes, and snippets.

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 {
@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;
/**
@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' );
@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;
},
@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 = [
@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';
@nclavaud
nclavaud / MangoPayApiPhpUnitMock.php
Created Apr 20, 2017
MangoPay API PHPUnit mock
View MangoPayApiPhpUnitMock.php
<?php
namespace Lrqdo\Tests;
use MangoPay\ApiWallets;
use MangoPay\MangoPayApi;
use MangoPay\Money;
use MangoPay\Wallet;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@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"
@treetop1500
treetop1500 / FlatpickerDateTimeType.php
Last active Feb 2, 2021
Symfony3 Form Extension for use with Flatpickr javascript date/time pickers
View FlatpickerDateTimeType.php
<?php
namespace MyBundle\Form\Extension;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
/**
* Class FlatpickrDateTimeType
* @package MyBundle\Form\Extension