Skip to content

Instantly share code, notes, and snippets.

@trshafer
trshafer / gist:519251
Created August 11, 2010 16:24
git ps1
# 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 {
@spulec
spulec / pre-commit
Last active January 13, 2023 02:26
Yipit Pre-commit Hook
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^[MA]\s+(?P<name>.*)$')
CHECKS = [
@leylaso
leylaso / pad.js
Created March 28, 2012 04:18
custom pad.js file for etherpad-lite allows setting author names as line numbers
/**
* @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;
/**
@suzuki
suzuki / mail2.php
Created February 2, 2014 23:51
Swift Mailer sample / DKIM email
<?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';
@maxgalbu
maxgalbu / Switch_Node.php
Last active December 31, 2019 16:03
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
@lumpysimon
lumpysimon / wp-disable-rest.php
Created November 26, 2015 22:44
Completely disable WordPress REST API
add_filter( 'rest_enabled', '_return_false' );
add_filter( 'rest_jsonp_enabled', '_return_false' );
@Seldaek
Seldaek / bench.php
Created December 8, 2015 10:33
strtr vs str_replace benchmark
<?php
$jobs = array(
'old/strtr' => function($args) {
$classes = [];
foreach ($args as $class) {
$classes[] = strtr($class, '\\', DIRECTORY_SEPARATOR);
}
return $classes;
},
@treetop1500
treetop1500 / FlatpickerDateTimeType.php
Last active September 10, 2022 08:52
Symfony3 Form Extension for use with Flatpickr javascript date/time pickers
<?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
@nclavaud
nclavaud / MangoPayApiPhpUnitMock.php
Created April 20, 2017 17:14
MangoPay API PHPUnit mock
<?php
namespace Lrqdo\Tests;
use MangoPay\ApiWallets;
use MangoPay\MangoPayApi;
use MangoPay\Money;
use MangoPay\Wallet;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@gnutix
gnutix / Fixture.yml
Last active March 14, 2024 04:53
Custom Faker Provider for generating Symfony encoded password using UserPasswordEncoderInterface.
Symfony\Component\Security\Core\User\User:
member:
__construct: ['member', '<symfonyPassword("Symfony\Component\Security\Core\User\User", "member", "salt")>', ['ROLE_USER']]
admin:
__construct: ['admin', '<symfonyPassword("Symfony\Component\Security\Core\User\User", "admin", "salt")>', ['ROLE_ADMIN']]