This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#rh-like service primitive wrapper for launchctl | |
usage() | |
{ | |
echo "usage: service <name> <start|stop>">&2 | |
} | |
[ $# -ne 2 ] && { | |
usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE VIEW percona.innodb_lock_blocks AS | |
SELECT ilw.requesting_trx_id AS requesting_trx_id, | |
ilw.blocking_trx_id AS blocking_trx_id, | |
itrxr.trx_started AS requesting_trx_started, | |
itrxb.trx_started AS blocking_trx_started, | |
itrxr.trx_mysql_thread_id AS requesting_mysql_thread_id, | |
itrxb.trx_mysql_thread_id AS blocking_mysql_thread_id, | |
itrxr.trx_query AS requesting_query, | |
itrxb.trx_query AS blocking_query, | |
itrxr.trx_started AS requesting_trx_started, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# as introduced here: http://fernandoipar.com/2011/03/10/piping-data-to-multiple-processes/ | |
usage() | |
{ | |
cat <&2 | |
usage : multi-fifo target0 [target1 [target2 [...]]] | |
Where each targetN is a program you want to send the input multi-fifo receives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func mainLoop() { | |
fmt.Println("starting main loop, this will die after dividing by 0") | |
i := 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns the individual fields for a dsn, or an error | |
func ParseDSN(input string) (error error, host string, port string, user string, password string, database string) { | |
args := strings.Split(string(input), ",") | |
if len(args) < 1 { | |
return errors.New("Seems like " + string(input) + " is not a valid dsn"), "", "", "", "", "" | |
} | |
for i := 0; i < len(args); i++ { | |
tmp := strings.Split(args[i], "=") | |
if len(tmp) < 2 { | |
return errors.New("I can't parse " + args[i]), "", "", "", "", "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "java" | |
require "clojure.jar" | |
java_import "clojure.lang.LockingTransaction" | |
java_import "clojure.lang.Ref" | |
counter = Ref.new(0) | |
puts "Initial value : #{counter.deref}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[ $# -eq 0 ] && { | |
echo "usage: salt <length>">&2 | |
exit | |
} | |
strings </dev/urandom | while read line; do | |
echo $line | tr '\n\t ' $RANDOM:0:1 >> /tmp/.salt.$$ | |
salt=$(cat /tmp/.salt.$$) | |
[ ${#salt} -ge $1 ] && salt=${salt:0:$1} && echo $salt && break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@lucid64:~/mootools# ./xbackup.sh full | |
Backup type: full | |
Backup job started: Tue May 7 18:01:40 PDT 2013 | |
Running full backup /backup//bkps/2013-05-07_18_01_40 | |
Checking disk space ... (data: 29516) (disk: 75403716) | |
Xtrabackup started: Tue May 7 18:01:40 PDT 2013 | |
Backing up with: /usr/bin/innobackupex --no-timestamp /backup//bkps/2013-05-07_18_01_40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@lucid64:~/mootools# ./xbackup.sh | |
usage: xbackup.sh <type> [ts] [incremental-basedir] | |
Where | |
<type> is full or incr | |
[ts] is a timestamp to mark the backup with. defaults to $(date +%Y-%m-%d_%H_%M_%S) | |
[incremental-basedir] if <type> is incr, this will be passed to --incremental-basedir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#very simple script to track time spent on tasks | |
#assumes: | |
# - you are single threaded, so no concurrent tasks | |
# - if you punch in to a task while you are punched into another one, you're punched out from the latter | |
# - you only care about accuracy down to minute intervals | |
# - you have a running mysql instance in localhost | |
# - you're not replicating this anywhere, you don't expect this to grow a lot, since the schema is stupid and has no keys other than PK, etc. This is only meant to help you track your daily work hours, you should be permanently saving those somewhere else. | |
# - you just want to track time. you don't really care about performance for this little helper script (i.e. it runs the CLI several times in a row instead of keeping an open connection) |
OlderNewer