Skip to content

Instantly share code, notes, and snippets.

@flug
flug / composer-update.sh
Last active August 29, 2015 14:07
dynamize
function composer-update (){
echo "-- composer update --"
$(which hhvm) $(which composer) self-update
$(which hhvm) $(which composer) update -vvv --profile --no-scripts && $(which php) $(which composer) run-script post-update-cmd
echo "-- composer update end --"
}
@mathiasverraes
mathiasverraes / PassThroughNamingStrategy.php
Created March 15, 2013 13:03
JMSSerializer PassThroughNamingStrategy
<?php
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use JMS\Serializer\Metadata\PropertyMetadata;
class PassThroughNamingStrategy implements PropertyNamingStrategyInterface
{
/**
* Translates the name of the property to the serialized version.
*
@Gisleburt
Gisleburt / pre-commit
Last active May 10, 2016 14:53
A pre-commit script for my PHP project for Git
#!/usr/bin/php
<?php
// Based on code by raphaelstolt and buddhamagnet https://gist.github.com/raphaelstolt/588697
class PreCommitHook {
protected $green = "\033[0;32m";
protected $red = "\033[0;31m";
protected $reset = "\033[0m";
@wowo
wowo / PHPUnit way to mock Doctrine2 Entity Manager.php
Created November 1, 2011 20:22
PHPUnit's way to mock Doctrine2 Entity Manager
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = $this->getMock('\Doctrine\ORM\EntityManager',
array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false);
$emMock->expects($this->any())
->method('getRepository')
@philipashlock
philipashlock / index.html
Last active March 15, 2021 10:39
ISO 8601 Date Validation
<html lang="en">
<head>
</head>
<body>
<pre>
<script type="text/javascript">
@bittner
bittner / 60-jetbrains.conf
Created September 25, 2015 07:57
Inotify configuration for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm). Create this file with e.g. `sudo vim /etc/sysctl.d/60-jetbrains.conf`
# Set inotify watch limit high enough for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm).
# Create this file as /etc/sysctl.d/60-jetbrains.conf (Debian, Ubuntu), and
# run `sudo service procps start` or reboot.
# Source: https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
#
# More information resources:
# -$ man inotify # manpage
# -$ man sysctl.conf # manpage
# -$ cat /proc/sys/fs/inotify/max_user_watches # print current value in use
@xpepper
xpepper / LondonVsChicago.md
Last active November 4, 2023 22:57
London vs Chicago, Comparative Case Study - Sandro Mancuso and Uncle Bob

My notes on the video series "London vs Chicago TDD styles" by Uncle Bob And Sandro Mancuso

The git repo of the kata is here: https://github.com/sandromancuso/cleancoders_openchat/

The "starting-point" branch is where both implementations began: https://github.com/sandromancuso/cleancoders_openchat/tree/starting-point

  • The 🇬🇧 "openchat-outside-in" branch captures the tomato by tomato history of the London approach.
  • The 🇺🇸 "openchat-unclebob" branch captures the tomato by tomato history of the Chicago approach.

What I like about Sandro's style 👍

@AndreasMadsen
AndreasMadsen / gist:2693051
Created May 14, 2012 10:04
base64 shim [atob, btoa]
// Source: http://code.google.com/p/gflot/source/browse/trunk/flot/base64.js?r=153
/* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
* Version: 1.0
* LastModified: Dec 25 1999
* This library is free. You can redistribute it and/or modify it.
*/
/*
* Interfaces:
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@tjamps
tjamps / README.md
Last active February 29, 2024 14:57
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :