Skip to content

Instantly share code, notes, and snippets.

View mpratt's full-sized avatar

Michael Pratt mpratt

View GitHub Profile
@nikic
nikic / accessors.markdown
Created October 13, 2012 11:22
Analysis of getter/setter usage in Symfony and Zend Framework

In order to get a bit of "hard data" on what accessors will actually be used for once they are introduced I wrote a small script that scans through a codebase, finds all getter and setter methods and checks them for various characteristics. (The analyze.php file in this Gist.)

Here are the results of running it on a Symfony (Standard) skeleton.

absoluteTotal        => 18516 (486.6%)
total                =>  3805 (100.0%)
skipped              =>   124 (  3.3%)
@mjtorn
mjtorn / config_flake8
Last active January 18, 2017 03:40
Using pylint with Syntastic for Vim makes it really slow. flake8 seems to catch the most relevant errors, but I like to disable some of them.
# Accually is ~/.config/flake8
[flake8]
max-line-length = 120
# E265: The one about comments starting '# '
# E127,E128: Errors about inline alignment
# W391: blank line at EOF. Of course you want a blank line there.
# F403: from foo import * is sometimes too useful$
ignore = E265,E127,E128,W391,F403
@adaburrows
adaburrows / functional_fibonacci.php
Created April 25, 2011 04:02
Functional Programming in PHP
<?php
/**
* Fibonacci:
*============================================================================
* Class for computing fibonacci numbers using functional programming in PHP
* Uses the formula at: http://jburrows.wordpress.com/2009/12/30/fibonacci/
*/
class fibonacci {
@rk
rk / bcrypt.php
Last active January 4, 2018 13:15
Simple bcrypt object to wrap crypt() with.
<?php
// Originally by Andrew Moore
// Src: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php/6337021#6337021
//
// Heavily modified by Robert Kosek, from data at php.net/crypt
class Bcrypt {
private $rounds;
private $prefix;
@ircmaxell
ircmaxell / password.php
Created June 18, 2012 16:53
Password API Example
<?php
define('PASSWORD_SHA256', '$5$');
define('PASSWORD_SHA512', '$6$');
define('PASSWORD_BCRYPT', '$2y$');
define('PASSWORD_SCRYPT', '$7$'); // made up here
$password_algos = array();
function password_register_algo($prefix, Callable $create, Callable $validate) {
@wookiecooking
wookiecooking / aliases.sh
Created November 30, 2013 00:52
[Shell] Assortment of OSX influenced bash aliases and functions
# Rails Stuff
alias stoprails='kill -9 $(lsof -i :3000 -t)'
alias startrails='rails server -d'
alias restartrails='stopRails && startRails'
#Check PHP For Erroes
alias phpcheck='find ./ -name \*.php | xargs -n 1 php -l'
# ROT13-encode text. Works for decoding, too! ;)
alias rot13='tr a-zA-Z n-za-mN-ZA-M'
@nikic
nikic / php-5.5-features.md
Last active August 31, 2020 10:39
List of new features in PHP 5.5
@murtaugh
murtaugh / 1. single-line.html
Last active April 21, 2021 16:23
Blockquote patterns for ALA
<figure class="quote">
<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote>
</figure>
@nikic
nikic / php_evaluation_order.md
Last active October 19, 2021 05:47
Analysis of some weird evaluation order in PHP

Order of evaluation in PHP

Yesterday I found some people on my [favorite reddit][lolphp] wonder about the output of the following code:

<?php

$a = 1;
$c = $a + $a++;