Skip to content

Instantly share code, notes, and snippets.

View fipar's full-sized avatar

Fernando Ipar fipar

View GitHub Profile
#!/bin/bash
sysbench \
--test=/usr/share/doc/sysbench/tests/db/insert.lua \
--mysql-host=127.0.0.1 \
--mysql-port=3306 \
--mysql-user=sysbench \
--mysql-password=sysbench \
--mysql-db=sysbench \
--mysql-table-engine=innodb \
--oltp-test-mode=complex \
@fipar
fipar / general_log.sql
Created July 15, 2015 17:07
export mysql.general_log into a text file with general log format
select 'Tcp port: 3306 Unix socket: /tmp/mysql.sock\nTime Id Command Argument'
union
select concat(date_format(event_time, '%y%m%d %H:%i:%S'), ' ', thread_id, ' ', command_type, '\t', argument)
from general_log
into outfile '/tmp/test'
fields terminated by ''
@fipar
fipar / gist:570d4dbad37c51ad523c
Created June 27, 2015 21:54
simple-todo meteor app using tokumx, on mac.

These are instructions on getting the simple-todo test app from the meteor tutorial (link below) running on a Mac and using TokuMX instead of MongoDB. It was written in response to this request: https://www.percona.com/blog/2015/05/08/mongodb-percona-tokumxse-experimental-build-rc5-available/#comment-10864682

Prerequsites:

@fipar
fipar / find_orphans.js
Created June 10, 2015 16:19
Find orphaned documents in mongodb (for pre 2.6 where cleanupOrphaned does not exist).
var database = "sample";
var collection = "tests";
var connections = [];
config = db.getMongo().getDB("config");
config.shards.find().forEach(
function (shard,_a,_i) {
connections.push(new Mongo(shard["host"]));
}
@fipar
fipar / worker_pool_example.sh
Created November 20, 2014 13:20
worker pool in bash
#!/bin/bash
THREADS=3
worker()
{
echo "thread $1 starting"
sleep 3
rm -f /tmp/lock.$1
echo "thread $1 finished"
@fipar
fipar / gist:3bf5b48685e89e7199f3
Created October 31, 2014 17:06
sample joomla queries
EXPLAIN SELECT a.title, a.description AS text, '' AS created, '2' AS browsernav, a.id AS catid, CASE WHEN CHAR_LENGTH(a.alias) != 0 THEN CONCAT_WS(':', a.id, a.alias) ELSE a.id END as slug FROM j_categories AS a WHERE (a.title LIKE '%super%' OR a.description LIKE '%super%') AND a.published IN (1,2) AND a.extension = 'com_content'AND a.access IN (1,1,2,3,6) GROUP BY a.id, a.title, a.description, a.alias ORDER BY a.title DESC LIMIT 0, 50;
EXPLAIN SELECT a.name AS title, '' AS created, a.con_position, a.misc, CASE WHEN CHAR_LENGTH(a.alias) != 0 THEN CONCAT_WS(':', a.id, a.alias) ELSE a.id END as slug, CASE WHEN CHAR_LENGTH(c.alias) != 0 THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as catslug, CONCAT_WS(',', a.name, a.con_position, a.misc) AS text,CONCAT_WS(' / ', 'Contacts', c.title) AS section,'2' AS browsernav FROM j_contact_details AS a INNER JOIN j_categories AS c ON c.id = a.catid WHERE (a.name LIKE '%super%' OR a.misc LIKE '%super%' OR a.con_position LIKE '%super%' OR a.address LIKE '%super%' OR a.s
@fipar
fipar / split_processlist
Created April 3, 2014 14:30
split pt-stalk processlist capture into individual files per timestamp, including only the query text and not 'NULL' queries. meant to then feed pt-query-digest --type rawlog
cnt=-1
f = nil
File.open(ARGV[0]).each_line do |line|
if line.match "^TS"
f.close unless f.nil?
f = File.open(line.gsub(" ","_"), 'w')
else
f.write(line.gsub(" Info: ","")) if line.match " Info: " and not line.match " Info: NULL"
end
end
@fipar
fipar / jruby-clojure-stm.rb
Created March 14, 2014 00:25
thread safe attribute accessors using clojure Atoms
require "java"
class Class
def atom_attr_accessor(*args)
self.class_eval("
require 'clojure.jar'
java_import 'clojure.lang.LockingTransaction'
java_import 'clojure.lang.Atom'
")
-- build binary with:
-- ghc --make -o hello maintest.hs
module Main where
main = putStrLn "Hello, world"