Skip to content

Instantly share code, notes, and snippets.

# add your user to www-data and vise versa
sudo usermod -a -G www-data myusername
sudo usermod -a -G myusername www-data
# override umask in ~/.bashrc and /etc/init.d/apache2
umask 002
#restart
@bxt
bxt / RingBuffer.class.php
Created September 7, 2011 13:15
One-pointer Circular Buffer w/o overflow check and FIFO, using SplFixedArray
<?php
/**
* One-pointer Circular Buffer
*
* This comes without any overwrite
* checks or FIFO functionality.
* You'll need SPL.
*
* @author Bernhard Häussner
* @date 2011-09-07
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@brtriver
brtriver / BasicAuthControllerProvider.php
Created February 4, 2012 20:36
Simple Basic Auth Controller for Silex.
<?php
namespace Silex\Provider;
use Silex\Application;
use Silex\SilexEvents;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@mattattui
mattattui / deploy.sh
Created January 5, 2013 09:48
Simple default-safe rsync deployment script
#!/bin/bash
# Will add --dry-run unless the --go option is set. All other arguments passed to rsync (e.g. --delete)
SOURCE=.
DEST=example.com:/var/www/mysite
DRYRUN="--dry-run"
args=()
for var in "$@"
@defrag
defrag / gist:4547311
Created January 16, 2013 14:02
Beanstalkd command line process for listening to symfony2 bg jobs.
<?php
namespace PW\ApplicationBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand,
Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputInterface,
Symfony\Component\Console\Input\StringInput,
Symfony\Component\Console\Output\OutputInterface;
@DaveRandom
DaveRandom / file.php
Last active December 12, 2015 03:38
Simple file upload manager lib
<?php
namespace Upload;
class File implements IFile {
/**
* The meta data about the file (from the $_FILES array)
*
* @var array $uploadMeta
@philsturgeon
philsturgeon / gist:5465246
Last active May 23, 2022 12:29
API Golden Rules

Never Expose DB Results Directly

  1. If you rename a field, then your users are fucked. Convert with a hardcoded array structure.
  2. Most DB drivers [for PHP] will show integers as numeric strings and false as "0", so you want to typecast them.
  3. Unless you're using an ORM with "hidden" functionality, people will see passwords, salts and all sorts of fancy codes. If you add one and forget to put it in your $hidden array then OOPS!

Use the URI sparingly, and correctly

  1. Use the query string for paired params instead of /users/id/5/active/true. Your API does not need to be SEO optimised.
  2. ?format=xml is stupid, use an Accept: application/xml header. I added this to the CodeIgniter Rest Server once for lazy people, and now people think it's a thing. It's not.
@igorw
igorw / README.md
Created December 17, 2013 16:18
Using laravel 4.1 CookieGuard middleware with silex.

Encrypted Cookies

This is an example of using laravel 4.1 CookieGuard middleware with silex. This demonstrates the composability of stack middlewares.

All of the outgoing cookies are encrypted. If decryption of incoming cookies fails, the application will ignore them.

Installation

Just clone the gist and install the dependencies via composer.

@mmcc
mmcc / b2dntp
Created September 11, 2014 16:49
boot2docker NTP update
#!/bin/sh
# Fix NTP/Time
# https://github.com/boot2docker/boot2docker/issues/290
boot2docker ssh -- sudo killall -9 ntpd
boot2docker ssh -- sudo ntpclient -s -h pool.ntp.org
boot2docker ssh -- sudo ntpd -p pool.ntp.org