Skip to content

Instantly share code, notes, and snippets.

# config/server.rb
require "em-synchrony"
require "em-synchrony/mysql2"
config['db'] = EM::Synchrony::ConnectionPool.new(:size => 25) do
::Mysql2::EM::Client.new({
:adapter => 'em_mysql2',
:database => 'shard001',
:username => 'xxx',
:password => 'xxx',
require 'benchmark'
require 'em-synchrony'
require 'em-synchrony/connection_pool'
require 'em-synchrony/activerecord'
require 'mysql2'
require 'active_record'
@balepc
balepc / tuning.sh
Created March 27, 2012 07:16
MySQL Tuning script
#!/bin/sh
#########################################################################
# #
# MySQL performance tuning primer script #
# Writen by: Matthew Montgomery <[email protected]> #
# Inspired by: MySQLARd (http://gert.sos.be/demo/mysqlar/) #
# Version: 1.5-r5 Released: 2009-11-22 #
# Licenced under GPLv2 #
# #
@balepc
balepc / mysqltuner.pl
Created March 27, 2012 07:17
MySQL Tuner Script
#!/usr/bin/perl -w
# mysqltuner.pl - Version 1.1.1
# High Performance MySQL Tuning Script
# Copyright (C) 2006-2009 Major Hayden - [email protected]
#
# For the latest updates, please visit http://mysqltuner.com/
# Git repository available at http://github.com/rackerhacker/MySQLTuner-perl
#
# 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
@balepc
balepc / redis-response-time.rb
Created September 10, 2012 06:12
Redis response-time monitor
#!/usr/bin/ruby
require 'rubygems'
require 'redis'
# Redis command processor. Author: Valery Vishnyakov
#
# Reports the following metrics
#
# CMD_PER_SEC Commands processed per second
@balepc
balepc / redis-migrator.rb
Created January 2, 2013 18:28
Move keys from multiple sources into one. Works only with strings
require 'rubygems'
require 'redis'
require 'uri'
class Redis
module Helper
def parse_redis_url(redis_url)
node = URI(redis_url)
puts 'jm1640424qm4l4vflo54ddkjm56l7hnhzx'.to_i(36).to_s(2).tr("01","#.").scan(/.{35}/)
for a in (36634234658,39796869174,51130141738,43496245282,43613571106):
print bin(a)[3:].replace('1','#').replace('0','.')
curl -s quiz.ask.fm|grep '##'|sed -e "s/<br\/>/\x0A/g" -e "s/ <p>//g" -e "s/<\/p>//g"
class t{public static void main(String[]r){for(int i=175;i>0;)System.out.print(new java.math.BigInteger("18s9jqdkp79cwvqpza2mwg1f1mbe9sgkdac",36).testBit(i--)?"#":i%35>0?".":".\r\n");}}