Skip to content

Instantly share code, notes, and snippets.

View pateketrueke's full-sized avatar

Alvaro Cabrera Durán pateketrueke

View GitHub Profile
@pateketrueke
pateketrueke / .bashrc
Created August 14, 2012 16:07
Open remote GitHub repository URL
hub(){
REPO="$(git remote -v | grep fetch | sed 's/origin//' | tr ':' '/' | sed 's/.*git@/http:\/\//' | sed 's/.git *([a-z]*)//')"
if [ "$(whereis xdg-open)" ] ; then
cmd="xdg-open"
else
cmd="open"
fi
$cmd "$REPO"
}
@pateketrueke
pateketrueke / wp-shot.php
Created August 9, 2012 23:13
Take screenshot using WP Remote API (fake)
<?php
$url = urlencode('http://wordpress.org');
$width = 200;
$request = "http://s.wordpress.com/mshots/v1/$url?w=$width";
echo "Link: $request";
@pateketrueke
pateketrueke / php_ext.sh
Created July 20, 2012 19:24
PHP extension compile skeleton / Heroku
cd /tmp
curl http://pecl.php.net/get/mongo/1.2.11 | tar xzf -
cd mongo-1.2.11
/app/php/bin/phpize
./configure --with-php-config=/app/php/bin/php-config
make && make install
cd ..
@pateketrueke
pateketrueke / install.sh
Last active October 7, 2015 10:47
Apache 2.2.24 & PHP 5.4.14 / Heroku pre-compile script
mkdir -p /app
# Prepare the filesystem
mkdir -p /tmp/build
cd /tmp/build
# Compiling Apache
curl http://www.us.apache.org/dist/httpd/httpd-2.2.24.tar.gz | tar xzf -
@pateketrueke
pateketrueke / stderr_logger.php
Created July 19, 2012 18:16
Logging for PHP with STDERR (Heroku compliant)
<?php
defined('STDERR') OR define('STDERR', fopen('php://stderr', 'w'));
logger::implement('write', function ($type, $message) {
$remote = server('REMOTE_ADDR');
$message = preg_replace('/[\r\n]+\s*/', ' ', $message);
fputs(STDERR, "$remote [$type] $message\n");
});
@pateketrueke
pateketrueke / php.ini
Created July 14, 2012 19:28
My default php.ini for PHP 5.4 under Windows7
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
@pateketrueke
pateketrueke / gist:2943149
Created June 17, 2012 02:06
Autoupload backtrace (manual)
ek@lamat:~/.local/lib/git/autoupload$ ruby listen.rb
/home/ek/.local/lib/git/autoupload/uploads/screenshot4.png
http://i.imgur.com/miGkN.png
/home/ek/.local/lib/git/autoupload/uploads/.listen_test
/home/ek/.local/lib/git/autoupload/imgur.rb:21:in `upload': undefined method `[]' for nil:NilClass (NoMethodError)
from /home/ek/.local/lib/git/autoupload/imgur.rb:27:in `upload_file'
from listen.rb:19:in `block in <main>'
from /usr/local/lib/ruby/gems/1.9.1/gems/listen-0.4.5/lib/listen/listener.rb:190:in `call'
from /usr/local/lib/ruby/gems/1.9.1/gems/listen-0.4.5/lib/listen/listener.rb:190:in `on_change'
from /usr/local/lib/ruby/gems/1.9.1/gems/listen-0.4.5/lib/listen/listener.rb:199:in `block in initialize_adapter'
@pateketrueke
pateketrueke / .bashrc
Created June 8, 2012 05:54
Zsh '$ vh' clone; works on Ubuntu/Mac OSX (fixed)
vh(){
paths[0]="/etc/apache2/sites-available"
paths[1]="/etc/apache2/extra/httpd-vhosts.conf"
paths[2]="/private/etc/apache2/virtualhosts"
paths[3]="/private/etc/apache2/extra/httpd-vhosts.conf"
for i in 0 1 2 3
do
if [ -f "${paths[$i]}" ] || [ -d "${paths[$i]}" ]; then
conf="${paths[$i]}"
@pateketrueke
pateketrueke / composer-example.php
Created May 28, 2012 05:45
Example loading through the Composer to run tetl:::PHP
<?php
require 'vendor/tetlphp/framework/initialize.php';
import('www');
run(function () {
root(function () {
echo 'Hello ', link_to('World', url_for::some_action());
@pateketrueke
pateketrueke / composer.json
Created May 28, 2012 05:42
Default composer configuration for tetl::PHP
{
"repositories": {
"pateketrueke": {
"package": {
"name": "tetlphp",
"version": "trunk",
"dist": {
"url": "https://github.com/pateketrueke/tetlphp/zipball/master",
"type": "zip"
}