Skip to content

Instantly share code, notes, and snippets.

View videlalvaro's full-sized avatar

Alvaro Videla videlalvaro

View GitHub Profile
http://twitter.com/janl brought me into attention about this interesting piece of code: http://www.davispj.com/2009/11/17/unix-in-python.html and this one: http://pwpwp.blogspot.com/2009/11/unix-in-14-lines-of-ruby-its-trivial.html which is implementing a barebones Unix like system in your favorite language
Here's my take on the game which is some pretty basic Haskell
You can run this code by calling runghc unix.lhs
> import System.IO
> main =
> putStrLn "You have no mail" >> loop
> where
> loop = putStr "$ " >> hFlush stdout >> getLine >>= doCommand
#/bin/sh
# run inside a symfony project:
# ./extractinfo.sh log/frontend_dev.log 'execute(Query|Update|Insert)' | sort -n
# will return the number of queries per request
# in symfony 1.2+ you can try something like:
# ./extractinfo.sh log/frontend_dev.log 'sfPropelLogger'
# you can modify the second parameter to extract the required information and also point
<?php
/*
new flag for xhprof_enable (third parameter) if set to false, instead of ignoring the passed array of
function names, it will profile only those functions.
Get it from: http://github.com/videlalvaro/xhprof
*/
$funcs = array('Memcache::get', 'array_deep_merge', 'sprintf', 'preg_match');
<?php
$enable_xhprof = apc_fetch('enable_xhprof');
if($enable_xhprof)
{
xhprof_enable(XHPROF_FLAGS_MEMORY, array('ignored_functions' => array('call_user_func',
'call_user_func_array')));
}
define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..'));
<?php
if($enable_graphite)
{
$fp = @fsockopen('127.0.0.1', 2003, $errno, $errstr, 1);
if($fp)
{
$out = array();
<?php
/**
The modifications to this class caches in APC all the file system scans that symfony does to find plugins paths, configurations files, modules, etc.
**/
class frontendConfiguration extends sfApplicationConfiguration
{
in file: AjaxController.php
<?php
/*
Performance wise, if you just need to return a simple text to the user
and you want to save resources, you may want to avoid loading the templating
system and return the text directly the the user
*/
<?php
/*
How to use:
Get this british words dictionary from here: http://www.curlewcommunications.co.uk/wordlist.html
IN PHP install the mypeb extension from source:
http://code.google.com/p/mypeb/
#!/bin/sh
#Example for unix like systems
# NOTE: Erlang must be already installed
# Download:
wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.7.2/rabbitmq-server-generic-unix-1.7.2.tar.gz
# Untar:
tar -xzvf rabbitmq-server-generic-unix-1.7.2.tar.gz
apc.cache_by_default On On
apc.canonicalize On On
apc.coredump_unmap Off Off
apc.enable_cli Off Off
apc.enabled On On
apc.file_md5 Off Off
apc.file_update_protection 2 2
apc.filters no value no value
apc.gc_ttl 3600 3600
apc.include_once_override Off Off