Skip to content

Instantly share code, notes, and snippets.

@stubbetje
stubbetje / base64.js
Created November 9, 2009 14:34
Base64 encode and decode in javascript
var Base64 = {
characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ,
encode: function( string )
{
var characters = Base64.characters;
var result = '';
var i = 0;
do {
@stubbetje
stubbetje / gist:422106
Created June 2, 2010 08:28
flatten an multidimensional array and combine keys with separator
<?php
$flatten = function( $array , $keySeparator = '.' ) use ( & $flatten )
{
if( is_array( $array ) ) {
foreach( $array as $name => $value ) {
$f = $flatten( $value , $keySeparator );
if( is_array( $f ) ) {
foreach( $f as $key => $val ) {
$array[ $name . $keySeparator . $key ] = $val;
@stubbetje
stubbetje / debug.unusedstylesheets.js
Created February 16, 2009 16:01
create list of unused stylesheet rules
// create list of unused stylesheet rules
$(document).ready(function()
{
var sel = [];
for( var s = 0 ; s < document.styleSheets.length ; s++ ) {
var rules = document.styleSheets[s].cssRules || document.styleSheets[s].rules;
for( var r = 0 ; r < rules.length ; r++ ) {
@stubbetje
stubbetje / strace.sh
Created February 17, 2012 20:42
strace all running httpd processes for troubleshooting
#!/bin/bash
#strace -s2048 -f $(ps auxfww | egrep -- php.*--fpm | egrep -v egrep | cut -d' ' -f 4 | sed -e 's/^/-p/g')
strace -f $(ps auxfww | egrep [h]ttpd | awk '{print $2}' | sed 's/^/-p/g') 2>&1
@stubbetje
stubbetje / audio.gpi
Created April 15, 2016 08:31
wave form from audio
#set output format and size
set term png size 320,180
#set output file
set output "audio.png"
# set y range
set yr [-1:1]
# we want just the data
@stubbetje
stubbetje / README.md
Created December 19, 2012 11:12
Installation notes of monitoring setup with graphite and statsd

Installation notes of monitoring setup with graphite and statsd

These are the notes for installing graphite and statsd.

To minimize system impact, all installations are done as a separate non-root user "mon". The resulting installation can be found in $HOME/graphite.

The only requirements that should be installed system wide are python and python-dev packages. Of course, the usual gcc chain should also be available

@stubbetje
stubbetje / .htaccess
Created March 7, 2012 11:54
RewriteBase problem with usage in multiple different directories
RewriteEngine On
RewriteBase /
RewriteRule ^SESS.{13}/(.*)$ $1 [L,QSA]
# all others, check if exists and if not, redirect to index.php (front controller)
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
@stubbetje
stubbetje / error_levels.php
Created July 8, 2011 14:14
Show what error levels are included in a given error_reporting() value
<?php
if( $_SERVER['argc'] === 1 ) {
printf(
'No error level specified as argument (%s <errorlevel>), using current error_reporting value...' . PHP_EOL
, $_SERVER['argv'][0]
);
$errorlevel = error_reporting();
} else {
@stubbetje
stubbetje / ExampleController.php
Created April 6, 2010 14:34
Gorilla_Controller_Action_Helper_Resource
<?php
class Example_Controller extends Zend_Controller_Action
{
public function indexAction()
{
$db = $this->getHelper('resource')->db;
}
}
@stubbetje
stubbetje / SplClassLoader.php
Created November 11, 2009 09:12 — forked from jwage/SplClassLoader.php
SplClassLoader
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.