Skip to content

Instantly share code, notes, and snippets.

View lorenzo's full-sized avatar

José Lorenzo Rodríguez lorenzo

View GitHub Profile
@lorenzo
lorenzo / remove_closing_tags.sh
Created June 1, 2011 06:42
Script to remove all closing ?> php tags in a folder
#!/bin/bash
# vim:ft=sh:ts=3:sts=3:sw=3:et:
###
# Strips the closing php tag `?>` and any following blank lines from the
# end of any PHP file in the current working directory and sub-directories. Files
# with non-whitespace characters following the closing tag will not be affected.
#
# Author: Bryan C. Geraghty <bryan@ravensight.org>
# Date: 2009-10-28
[color]
status = auto
branch = auto
interactive = auto
diff = auto
[instaweb]
httpd = webrick
port = 8000
[git-tmbundle "log"]
limit = 10
@lorenzo
lorenzo / gist:1246265
Created September 27, 2011 21:13
zmq logger
/**
* Publishes a message to using the ZeroMQ protocol
*
* @param string $type type of message
* @param string $message
* @return boolean
*/
public function write($type, $message) {
$context = new ZMQContext();
$publisher = $context->getSocket(ZMQ::SOCKET_PUB);
root@vmi2495:/etc/nginx/sites-enabled# cat test.it
server {
listen 80;
server_name test.it;
rewrite ^(.*) http://www.test.it$1 permanent;
}
server {
listen 80;
server_name www.test.it;
@lorenzo
lorenzo / gist:1988522
Created March 6, 2012 19:32
My nginx conf
# php.conf
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
index index.php;
@lorenzo
lorenzo / gist:3378435
Created August 17, 2012 12:23
Mapping
{
places: {
properties: {
Place: {
properties: {
capacity: {
type: "integer"
},
categories: {
type: "string",
-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 30, 2012 at 10:44 AM
-- Server version: 5.5.19
-- PHP Version: 5.4.3
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
define('NO_IDENTIFIER_ERROR', 600);
define('DUPLICATE_ACCOUNT_ERROR', 601);
define('INVALID_OAUTH_TOKEN', 602);
define('NOT_OWNER_ERROR', 603);
define('DUPLICATE_CHECKIN', 604);
define('VOUCHER_NOT_STARTED', 605);
define('VOUCHER_EXPIRED', 606);
define('VOUCHER_LIMIT_REACHED', 607);
define('DUPLICATE_VOUCHER_CLAIM', 608);
@lorenzo
lorenzo / AppModel.php
Created September 17, 2012 07:50
Soft delete in cakephp
/**
* Override Model::delete() to implement a soft-delete feature for this model
* requires the model to have a 'deleted' boolean column
*
* @return boolean
**/
public function delete($id = null, $cascade = true) {
if ($id === null) {
$id = $this->id;
}
<?php
class ParentFixture extends CakeTestFixture {
public $import = array();
protected $hasData = false;
protected static $truncating = false;
protected static $log = array();
public function insert($db) {
self::$truncating = false;