Skip to content

Instantly share code, notes, and snippets.

@lsmith77
lsmith77 / oss crowdfunding sites
Created February 8, 2013 08:54
List of crowd funding services that could be relevant for OSS projects
oss focused:
https://bountyoss.com
http://beex.org
http://www.freedomsponsors.org
http://selfstarter.us
not oss focused:
http://flattr.com
http://pledgie.com
http://www.launcht.com
@lsmith77
lsmith77 / gist:4194191
Created December 3, 2012 10:57
matching a list of prefixes, preg_match is of course also more flexible, but it seems like its also going to be faster in many cases
<?php
$iterations = 10000;
$url = '/foo/bar';
$list1 = array('/bar', '/ding', 'dong');
$list2 = array('/foo', '/bar', '/ding', 'dong');
$regexp1 = '/^\/(bar|ding|dong)/';
$regexp2 = '/^\/(bar|foo|ding|dong)/';
@lsmith77
lsmith77 / performance optimization gone wrong
Created November 23, 2012 15:37
we added MultivaluePropertyCollection to more efficiently handle detection if an array property in PHPCR ODM changed or not .. guess we actually reduced performance and prevented people from using array functions easily .. doh!
<?php
require 'vendor/doctrine/common/lib/Doctrine/Common/Collections/Collection.php';
require 'vendor/doctrine/common/lib/Doctrine/Common/Collections/Selectable.php';
require 'vendor/doctrine/common/lib/Doctrine/Common/Collections/ArrayCollection.php';
require 'vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/PersistentCollection.php';
require 'vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/MultivaluePropertyCollection.php';
use Doctrine\Common\Collections\ArrayCollection;
@lsmith77
lsmith77 / gist:4078842
Created November 15, 2012 14:22
stripping cookies for caching when using the Symfony2 HttpCache
<?php
require_once __DIR__.'/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class AppCache extends HttpCache
{
@lsmith77
lsmith77 / gist:872143
Created March 16, 2011 07:25
Add License info to Repository meta data
The symfony project is currently exploring ways to ensure that code contributors are aware that any pull request they send implies that their code is contributed under the MIT license. We are currently not yet convinced that we need a full blown CLA, especially since we are concerned about adding needless hurdles for contributions that git just so nicely reduced. Likely other projects have similar concerns.
So the idea is the following:
- In a git repository the admin can configure the location of the license file (either inside the repo or in theory also out side of the repo)
- In order to make life easier for users, github could provide template files so that they can easily add them to their repository
- Using those template files also makes it possible for github to determine the name of the license (aka when symfony uses the github MIT license template, then guthub can easily determine automatically that symfony uses the MIT license)
- The license information then becomes searchable.
- Maybe users can e
parameters:
dynamic.db.name: db1
doctrine:
dbal:
default_connection: db1
connections:
db1:
dbname: %dynamic.db.name%
user: db1_user
@lsmith77
lsmith77 / gist:812538
Created February 5, 2011 15:41
user controlled config merging
###
# uses http://yaml.org/type/merge.html
# imports read the given file and define implicit merge key alias for all possible paths
###
# config.yml
foo: bar
# implicitly defines a &ding merge key alias
ding:
@lsmith77
lsmith77 / gist:812402
Created February 5, 2011 11:58
move to a single load method
### Before ###
## Doctrine Configuration
doctrine.dbal:
dbname: xxxxxxxx
user: xxxxxxxx
password: ~
logging: %kernel.debug%
doctrine.orm:
auto_generate_proxy_classes: %kernel.debug%
mappings:
@lsmith77
lsmith77 / Symfony2-in-the-trenches.markdown
Created January 16, 2011 09:04
this is just some notes in preparation for the slides
@lsmith77
lsmith77 / less processing with php and symfony2
Created January 1, 2011 13:04
In development the CSS file is generated on the fly, while the file is stored permanently in the production build script.
<?php
// RewriteRule ^css/main.css$ dev/less/getcss.php?cssfile=main [L]
header("Cache-Control: no-cache");
header('Content-Type: text/css');
if (isset($_GET['cssfile'])) {
$cache = generatecss($_GET['cssfile']);
if (isset($cache['compiled']) && is_array($cache)) {