Skip to content

Instantly share code, notes, and snippets.

View malteo's full-sized avatar
🏠
Working from home

Matteo Giordano malteo

🏠
Working from home
View GitHub Profile
@malteo
malteo / gist:623753
Created October 13, 2010 09:42
Allowing Users To Invoke Methods Before A Component Is Rendered in ExtJS
/**
* Allowing Users To Invoke Methods Before A Component Is Rendered
*
* @see http://www.sencha.com/blog/2010/08/27/tips-and-tricks-for-ext-js-component-developers/
*/
someMethod: function() {
if (!this.rendered) {
this.on('render', this.someMethod, this, {single: true});
return;
@malteo
malteo / gist:1264387
Created October 5, 2011 13:12
How to use Monolog in any PHP file
<?php
spl_autoload_register(function ($class) {
$file = $__DIR__.'/relative/path/to/Monolog/src/'.strtr($class, '\\', '/').'.php';
if (file_exists($file)) {
require $file;
return true;
}
});
@malteo
malteo / sfWidgetFormSchemaFormatterBootstrap.class.php
Created November 11, 2011 09:21
Symfony form formatter to use with Twitter Bootstrap CSS
<?php
/**
* A FormSchemaFormatter to use with Twitter Bootstrap CSS.
*
* @author malteo
*/
class sfWidgetFormSchemaFormatterBootstrap extends sfWidgetFormSchemaFormatter
{
protected
@malteo
malteo / LocalStorageProvider.js
Created December 12, 2011 17:04
localStorage state provider for ExtJS 3
Ext.ns('Ext.ux.state');
/**
* @class Ext.ux.state.LocalStorageProvider
* @extends Ext.state.Provider
* A Provider implementation which saves and retrieves state via the HTML5 localStorage object.
* If the browser does not support local storage, an exception will be thrown upon instantiating
* this class.
* <br />Usage:
<pre><code>
from fabric.api import cd, env, local, prefix, run, sudo
env.hosts = ['cs01.actalis.vpn']
env.project_root = '/home/libersoft/visalaid'
env.user = 'libersoft'
def push():
local('git push')
#!/bin/bash
while read -r line
do
echo "$line$(pwgen -s 16 1)"
done < $1 >temp
mv temp $1
@malteo
malteo / gist:5310697
Created April 4, 2013 14:14
anche PHP ha i suoi momenti
$app->get('/admin/print/{course_id}/{generated}', function ($course_id, $generated) use ($app) {
$query = $app['idiorm']->getTable('keys')
->select('code')
->where('course_id', $course_id)
->where('generated', $generated);
$stream = function () use ($query) {
$out = fopen('php://output', 'w');
foreach ($query->find_array() as $key) {
fputcsv($out, $key);
@malteo
malteo / uptime.conf
Created April 10, 2013 14:06
Upstart script
# /etc/init/uptime.conf
description "uptime"
author "malte"
start on runlevel [2345]
stop on runlevel [^2345]
# Restart when job dies
respawn
<?php
/**
* This is what happens when you don't catch a case in your switches, Larry.
*/
class ShouldntHappenException extends \RuntimeException
{
const COMBO_BREAKER = 'C-C-C-COMBO BREAKER!';
/**
@malteo
malteo / index.html
Last active December 29, 2015 23:59
URLbot
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>URLbot</title>