Skip to content

Instantly share code, notes, and snippets.

@pborreli
pborreli / import
Created May 10, 2010 14:42
Dealing with mass import in doctrine/pdo using pcntl_fork
<?php
class importTask extends sfTask
{
protected function execute($arguments = array(), $options = array())
{
$xml = simplexml_load_file('file');
$users = array();
foreach ($xml->users as $user)
{
<?php
mysql_connect('localhost', 'root', '') or
die('cannot connect : ' . mysql_error());
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
body { font-family: arial, helvetica, sans-serif; font-size: 10pt; margin: 0; }
table { border-collapse: collapse; margin: auto; }
@n1k0
n1k0 / include.js
Created December 22, 2011 08:24
Simple javascript include
function include(url) {
var element;
switch (url.split(".").pop()) {
case "css":
{
element = document.createElement("link");
element.setAttribute("rel", "stylesheet");
element.setAttribute("type", "text/css")
element.setAttribute("href", url)
}
@kriswallsmith
kriswallsmith / QSAListener.php
Created August 8, 2012 18:23
implements QSA on Symfony2 redirects
<?php
use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/** @DI\Service */
class QSAListener
{
private $blacklist;
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@chanmix51
chanmix51 / create-pomm-silex.sh
Last active February 25, 2018 17:11
Silex project bootstrap with Pomm
#!/bin/bash
mkdir -p bin sources/{config,twig,sql,lib/{Model,Controller}} web/{css,images,js} tests documentation log
chmod 777 log
> web/favicon.ico
cat > bin/generate_model.php <<"EOF"
<?php // bin/generate_model.php
$app = require(__DIR__."/../sources/bootstrap.php");
@drinks
drinks / deploy.rb
Created October 11, 2012 21:33
Cap recipe for wordpress using nginx, php-fpm and W3 Total Cache
default_run_options[:pty] = true
set :application, "<your-application-folder-name>"
set :domain, "<your-ip-addr>"
set :user, "<your-deploy-user>"
set :group, "<your-deploy-group>"
set :runner, "<your-deploy-user>"
set :use_sudo, true
set :scm, :git
set :deploy_via, :remote_cache
set :repository, "git@github.com:your-account/your-repo.git"
@chanmix51
chanmix51 / SessionMap.php
Created October 25, 2012 13:17
REST API with Silex and Pomm
<?php
namespace Taf\Member;
use Taf\Member\Base\SessionMap as BaseSessionMap;
use Taf\Member\Session;
use \Pomm\Exception\Exception;
use \Pomm\Query\Where;
use \Pomm\Object\BaseObject;
@Seldaek
Seldaek / LoggerInterface.php
Created November 16, 2012 10:35
LoggerInterface PSR Proposal
<?php
namespace PSR\Log;
/**
* Describes a logger instance
*
* The message MUST be a string.
*
* The context array can contain arbitrary data, the only assumption that
[alias]
fixup = !sh -c 'REV=$(git rev-parse $1) && git commit --fixup $@ && git rebase -i --autosquash $REV^' -
squash = !sh -c 'REV=$(git rev-parse $1) && git commit --squash $@ && git rebase -i --autosquash $REV^'