Skip to content

Instantly share code, notes, and snippets.

curl -s quiz.ask.fm|grep '##'|sed -e "s/<br\/>/\x0A/g" -e "s/ <p>//g" -e "s/<\/p>//g"
for a in (36634234658,39796869174,51130141738,43496245282,43613571106):
print bin(a)[3:].replace('1','#').replace('0','.')
puts 'jm1640424qm4l4vflo54ddkjm56l7hnhzx'.to_i(36).to_s(2).tr("01","#.").scan(/.{35}/)
@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)
@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 / 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 / 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 #
# #
require 'benchmark'
require 'em-synchrony'
require 'em-synchrony/connection_pool'
require 'em-synchrony/activerecord'
require 'mysql2'
require 'active_record'
# 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',
@balepc
balepc / ec2_http_health.rb
Created September 15, 2011 13:25
Scout plugin for checking HTTP statuses on AWS EC2
# EC2 Http servers health status
# * Number of running instances
# * Average response time
class Ec2HttpHealth < Scout::Plugin
needs 'right_aws'
needs 'timeout'
OPTIONS=<<-EOS
access_key_id: