Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pasamio
pasamio / .profile
Created February 14, 2014 23:40
Copy of my .profile for environments with shared NFS home directories (per server history file)
export PS1='\h:\W \u\$ '
alias v='ls -lh'
alias vv="du --max-depth=1 -k | sort -n | cut -f2 | xargs -d '\n' du -sh"
# Let the computer remember that which would otherwise be forgotten.
# Append to the history otherwise multiple tabs clobber each other.
shopt -s histappend
# Set the number of entries in the history file to be sufficiently large.
@pasamio
pasamio / hack.sh
Created April 5, 2012 05:27 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
# Compile PCRE - Perl Compatible Regular Expressions
cd /usr/local/src
curl -O ftp://ftp.csx.cam.ac.uk//pub/software/programming/pcre/pcre-8.32.tar.gz
tar -xvzf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make
sudo make install
# Compile Autoconf
@pasamio
pasamio / gist:8365179
Created January 11, 2014 00:13
Quick one-liner to put a query in the query log to help figure out ordering for queries similar to profiling marks.
JFactory::getDbo()->setQuery("SELECT 'beforeCActivities::_getData_getActivities'")->execute(); // Query progress mark
@pasamio
pasamio / userstats.php
Created January 11, 2014 00:09
Joomla! CLI Script to collect user stats such as active sessions and also to calculate churn. Includes install script to create tables.
<?php
/**
* @package Joomla.CLI
* @subpackage cli_userstats
*/
// Make sure we're being called from the command line, not a web interface
if (array_key_exists('REQUEST_METHOD', $_SERVER)) die();
@pasamio
pasamio / gist:8365793
Created January 11, 2014 01:27
Quick line to put in Joomla debug plugin to output queries to a log file. Put just after the $log = $db->getLog() line.
<?php
file_put_contents('/tmp/joomla_querylog_' . time() . '.log', implode("\n", array_map(function ($item) { return str_replace("\n", " ", $item); }, $log)));
@pasamio
pasamio / gist:8365784
Created January 11, 2014 01:25
Snippet to output usable debugging to an external file in situations where the template may not play nice with debug or when the debug output may be a couple of MB larger. Also useful for comparing various page loads, AJAX requests and a few other things.
<?php
$header[] = '<html>';
$header[] = '<head>';
$header[] = '<script src="https://code.jquery.com/jquery.js"></script>';
$header[] = '<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>';
$header[] = '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">';
$header[] = '</head>';
$header[] = '<body style="background-color: lightgrey">';
$footer[] = '</body>';
$footer[] = '</html>';
<?php
// Load the builder class for the core.php file.
jimport('grisgris.builder.registry');
jimport('grisgris.builder.builder');
jimport('grisgris.builder.aggregate');
jimport('grisgris.builder.generic');
jimport('grisgris.builder.cache');
jimport('grisgris.builder.table');
jimport('grisgris.provider.provider');
<?php
/**
* @package Gris-Gris.Skeleton
* @subpackage Builder
*
* @copyright Copyright (C) 2014 Respective authors. All rights reserved.
* @license Licensed under the MIT License; see LICENSE.md
*/
namespace Grisgris\Builder;
@pasamio
pasamio / gist:8674045
Created January 28, 2014 19:06
Simple command to get a list of larger directories (100MB or more)
du -sm * | sort -g -r | egrep ^[0-9]{3}