Skip to content

Instantly share code, notes, and snippets.

@vitorbrandao
vitorbrandao / php-sanitize-filename
Created April 25, 2011 15:52
Sanitize PHP filenames for UNIX/Linux
<?php
/**
* Helper holds a collection of static methods, useful for generic purposes
*/
class Helper
{
/**
* Returns a safe filename, for a given platform (OS), by replacing all
* dangerous characters with an underscore.
@vitorbrandao
vitorbrandao / composer.json
Created May 28, 2012 10:45
composer.json for the Smarty template engine (trunk)
{
"name": "smarty/smarty",
"type": "library",
"description": "Smarty - the compiling PHP template engine",
"keywords": ["templating"],
"homepage": "http://www.smarty.net",
"license": "LGPLv3",
"authors": [
{
"name": "Monte Ohrt",
@vitorbrandao
vitorbrandao / overlay.py
Created July 28, 2012 21:04
Portage API - Return all packages available in given Overlay [Gentoo Linux]
import portage
from gentoolkit.package import Package
def get_all_packages(overlay_path):
"""Returns all packages from a given overlay path.
"""
packages = {}
porttree = portage.db[portage.root]['porttree']
vartree = portage.db[portage.root]['vartree']
@vitorbrandao
vitorbrandao / gist:5323678
Created April 6, 2013 00:25
PPI app/console
$ ./app/console
PPI version 2.1.0-DEV - development/debug
Usage:
[options] command [arguments]
Options:
--help -h Display this help message.
--quiet -q Do not output any message.
--verbose -v Increase verbosity of messages.
@vitorbrandao
vitorbrandao / GlobalVariablesContainer.php
Created March 14, 2014 13:18
SmartyBundle - Assign variables to every template
<?php
namespace Vendorx;
class GlobalVariablesContainer
{
protected $vars;
public function __construct($three = 3)
{

Keybase proof

I hereby claim:

  • I am noisebleed on github.
  • I am noiselabs (https://keybase.io/noiselabs) on keybase.
  • I have a public key whose fingerprint is 3AAB E94B 277F 7D44 29AB 4318 9944 5351 2250 E987

To claim this, I am signing this object:

@vitorbrandao
vitorbrandao / python-exec2.broken.py
Last active August 29, 2015 14:10
/usr/lib64/python-exec/python-exec2 (broken)
#!/usr/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'Sphinx==1.1.3','console_scripts','sphinx-autogen'
__requires__ = 'Sphinx==1.1.3'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('Sphinx==1.1.3', 'console_scripts', 'sphinx-autogen')()
)
@vitorbrandao
vitorbrandao / python-exec
Created November 21, 2014 10:35
/usr/lib64/python-exec/python-exec2 (broken)
#!/usr/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'Sphinx==1.1.3','console_scripts','sphinx-autogen'
__requires__ = 'Sphinx==1.1.3'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('Sphinx==1.1.3', 'console_scripts', 'sphinx-autogen')()
)
@vitorbrandao
vitorbrandao / python-exec2.original.py
Created November 21, 2014 10:39
/usr/lib64/python-exec/python-exec2
#!/usr/lib/python-exec/python-exec2-c
# vim:fileencoding=utf-8:ft=python
# (c) 2012 Michał Górny
# Released under the terms of the 2-clause BSD license.
#
# This is not the script you are looking for. This is just a wrapper.
# The actual scripts of this application were installed with -python*,
# -pypy* or -jython* suffixes. You are most likely looking for one
# of those.
@vitorbrandao
vitorbrandao / ghost-upgrade.py
Created December 11, 2014 14:10
Ghost upgrade script (Python)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Vítor Brandão <vitor@noiselabs.org>
import subprocess
from contextlib import closing
import glob
import os
import requests