Skip to content

Instantly share code, notes, and snippets.

# Install Guide for Sugar on CentOS
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs
@xzirrow
xzirrow / virtualhosts2local.sh
Created May 8, 2014 09:22
If you wish to test your webapp you can use this
for host in $( httpd -S | grep -i "port 80" | awk '{ print $4; }'); do echo "127.0.0.1 $host" >> /etc/hosts; done;
<?php
use Symfony\Component\HttpFoundation\Response;
$app->get('/login', function () use ($app) {
$username = $app['request']->server->get('PHP_AUTH_USER', false);
$password = $app['request']->server->get('PHP_AUTH_PW');
if ('igor' === $username && 'password' === $password) {
$app['session']->set('user', array('username' => $username));
return $app->redirect('/account');
pt-query-digest --limit=100%:15 --report-format=query_report --report-histogram=no /var/log/mysql/mysql-slow5.log
Array.prototype.join = (function(_super) {
// return our new `join()` function
return function() {
console.log("Hey, you called join!");
return _super.apply(this, arguments);
};
// Pass control back to the original join()
// by using .apply on `_super`
@xzirrow
xzirrow / get_schema_tables_size
Created April 23, 2014 12:26
get_schema_tables_size
SELECT
concat(table_schema,'.',table_name) tablename,
table_rows as total_rows,
concat(round(data_length/(1024*1024),2),'M') data_size,
concat(round(index_length/(1024*1024),2),'M') index_size,
concat(round((data_length+index_length)/(1024*1024),2),'M') total_size,round(index_length/data_length,2) idxfrac
FROM information_schema.TABLES WHERE table_schema = '/* your shema name */' ORDER BY data_length+index_length DESC
@xzirrow
xzirrow / log.lua
Created April 23, 2014 11:33 — forked from simonw/log.lua
--[[
Copyright (C) 2007 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
DBNAME=somedb
DBUSER=someuser
DBPASS=somepassword
# Used parenthesis for the initial 'mysql' command so we can have a heredoc and still
# pipe stdout back into mysql.
# The tail command skips the first line of output, so we have only the ALTER TABLE commands.
# After all that, pipe the output back into the mysql command.