Skip to content

Instantly share code, notes, and snippets.

@combatpoodle
combatpoodle / gtk-firefox.sh
Last active December 17, 2015 17:29 — forked from joekiller/gtk-firefox.sh
Updated to use current Amazon Linux packages for a most of dependencies.
#!/bin/bash
# GTK+ and Firefox for Amazon Linux
# Written by Joseph Lawson 2012-06-03
# http://joekiller.com
# http://joekiller.com/2012/06/03/install-firefox-on-amazon-linux-x86_64-compiling-gtk/
# chmod 755 ./gtk-firefox.sh
# sudo ./gtk-firefox.sh
@combatpoodle
combatpoodle / fastforward.py
Created May 28, 2013 23:38
Fast-forwards a DB slave through specific error numbers. Nifty if there are hundreds or thousands of them (think schema updates being run with bad timing...)
import MySQLdb, MySQLdb.cursors, time
skip_errno=1677L
db_user=''
db_passwd=''
db_host=''
db_db = ''
connection = MySQLdb.connect(host=db_host, user=db_user, passwd=db_passwd, db=db_db,cursorclass=MySQLdb.cursors.DictCursor, charset='UTF8')
cursor = connection.cursor()
@combatpoodle
combatpoodle / gist:5723198
Created June 6, 2013 17:17
Function to reliably retrieve a local IP address on OS X + Linux in Python. Interface specification only works on Linux.
# get_ip is from http://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib, added a fallback to making a connection for OS X/local testing
def get_ip(iface = 'eth0'):
import socket, struct, fcntl
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockfd = sock.fileno()
SIOCGIFADDR = 0x8915
ifreq = struct.pack('16sH14s', iface, socket.AF_INET, '\x00'*14)
@combatpoodle
combatpoodle / normalize_php_fpm_affinity.cron
Created June 29, 2013 05:18
Normalize PHP-FPM CPU affinity Assumes 8 processors, #0 assigned to kernel+nginx
* * * * * root /usr/local/bin/normalize_php_fpm_cpu_affinity.sh
@combatpoodle
combatpoodle / gist:5902537
Created July 1, 2013 16:50
thing I can't paste
foreach ($post->post_meta as $key => $value) {
$post->post_meta[ $key ] = ( isset( $value[0] ) && count( $value ) == 1 ) ? $value[0] : $value;
}
@combatpoodle
combatpoodle / generate.sh
Created July 19, 2013 19:11
Generate PHP RPM with apc, xdebug, memcache, imagick from PECL on RHEL/CentOS/Amazon Linux
cd ~ &&
sudo yum -y install mysql libtiff libXpm t1lib libc-client libmcrypt libtool-ltdl libicu cyrus-sasl-ldap freetds unixODBC aspell recode net-snmp libtidy ImageMagick libxslt libxml2 &&
sudo yum -y install libxml2-devel ImageMagick-c++-devel ImageMagick-devel aspell-devel freetds-devel libXpm-devel libc-client-devel libicu-devel libmcrypt-devel libtidy-devel libtiff-devel libtool-ltdl-devel libxslt-devel mysql-devel net-snmp-devel recode-devel t1lib-devel unixODBC-devel pcre-devel libcurl-devel libpng-devel libtiff-devel libjpeg-devel gmp-devel openldap-devel readline-devel libedit-devel &&
sudo yum -y install rubygems gcc ruby-devel &&
sudo gem install fpm &&
wget http://www.php.net/distributions/php-5.4.17.tar.bz2 &&
bunzip2 php-5.4.17.tar.bz2 &&
tar -xvf php-5.4.17.tar &&
cd php-5.4.17 &&
./configure '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-amazon-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/us
##
# Copyright (c) 2010 Mochi Media, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
def unserialize_session(val):
if not val:
return
session = {}
groups = re.split("([a-zA-Z0-9_]+)\|", val)
if len(groups) > 2:
groups = groups[1:]
groups = map(None, *([iter(groups)] * 2))
for i in range(len(groups)):
@combatpoodle
combatpoodle / gist:6645225
Created September 20, 2013 23:24
Switch from mysql 5.6 to percona 5.6
service mysql stop; yum -y remove MySQL-client MySQL-shared MySQL-server; yum -y install Percona-Server-shared-56.x86_64 Percona-Server-client-56.x86_64 Percona-Server-server-56.x86_64; service mysql start
@combatpoodle
combatpoodle / gist:7146987
Last active December 26, 2015 11:49
Patches percona-server-5.6.14-rel62.0 for compatibility with OS X 10.9... (update - fixed whitespace issue at end of patch...)
diff --git a/client/mysql.cc b/client/mysql.cc
index d8c7ae2..c78b5d8 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -238,8 +238,8 @@ static my_bool execute_buffer_conversion_done= 0;
The same is true for stderr.
*/
static uint win_is_console_cache=
- (test(my_win_is_console(stdout)) * (1 << _fileno(stdout))) |
- (test(my_win_is_console(stderr)) * (1 << _fileno(stderr)));