This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Elegant way to create an API URL | |
* | |
* Usage: | |
* $this->getResourceUrl('/product/%s/id-%d', 'edit', 13); | |
* // will produce http://domain.com/product/edit/id-13 | |
* | |
* // A resource can be an array to embed this method in an other method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rbconfig' | |
isWindows = /mswin|win|mingw|cygwin/i === RbConfig::CONFIG['host_os'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :branch, "master" | |
task :set_branch_revision do | |
default_tag = `git tag`.split("\n").last | |
tag = Capistrano::CLI.ui.ask "Tag to deploy (make sure to push the tag first): [#{default_tag}] " | |
if tag.empty? | |
default_revision = `git log origin/#{branch} -n 1 --pretty=format:%H` | |
default_short_revision = default_revision[0, 10] | |
revision = Capistrano::CLI.ui.ask "Revision to deploy (on branch #{branch}): [#{default_short_revision}] " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this repo to the /etc/apt/source.list file | |
deb ftp://ftp.debian.org/debian stable contrib non-free | |
# And run these commands | |
sudo apt-get update | |
sudo apt-get install ttf-mscorefonts-installer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once sfConfig::get('sf_lib_dir').'/vendor/lessphp/lessc.inc.php'; | |
class npDriverLessmin extends npDriverBase | |
{ | |
public function doProcessFile($file, $replace = false) | |
{ | |
$lessc = new lessc($file); | |
$optimizedContent = cssmin::minify($lessc->parse()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class npDriverJpegoptim extends npDriverBase | |
{ | |
public function doProcessFile($file, $replace = false) | |
{ | |
if (false === $replace) | |
{ | |
throw new LogicException('JPEG optimization only support file replacement atm'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyForm extends sfForm | |
{ | |
protected $robotProtectionFieldName = "_honeypot_robot"; | |
public function __construct($defaults = array(), $options = array(), $CSRFSecret = null) | |
{ | |
parent::__construct($defaults, $options, $CSRFSecret); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* SiteMapIndexXML | |
* | |
* A simple helper to make simple sitemap.xml of index | |
* | |
* Usage: | |
* $sitemap = new SiteMapIndexXML(); | |
* $sitemap->addSiteMap('http://example.org/sitemap-products.xml'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* SiteMapXML | |
* | |
* A simple helper to make simple sitemap.xml with images | |
* | |
* Usage: | |
* // without images | |
* $sitemap = new SiteMapXML(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
IP=`sudo docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${1}` | |
HOST=$2 | |
[ -z "$HOST" ] && exit 1; | |
sudo sed -i "s/.*\s${HOST}$/${IP} ${HOST}/" /etc/hosts |