Skip to content

Instantly share code, notes, and snippets.

View keyurdg's full-sized avatar

Keyur Govande keyurdg

View GitHub Profile
#!/bin/bash -x
# Michele Bini, the author of this script, disclaims copyright to it
# thus placing it in the public domain.
progname=`basename "$0"`
explain() {
cat <<EOF
Usage: $progname [-adt] [-p pid]|[executable]
@keyurdg
keyurdg / gist:11196897
Created April 22, 2014 22:43
dpwrite.c with DIRECT_IO
/var/lib/mysql/xfs/plain_pwrite_0.werr:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL FLAGS
0: [0..1023]: 1184..2207 0 (1184..2207) 1024 01111
1: [1024..8191]: 9472..16639 0 (9472..16639) 7168 00011
2: [8192..12287]: 20736..24831 0 (20736..24831) 4096 00011
3: [12288..16383]: 28928..33023 0 (28928..33023) 4096 00011
4: [16384..20479]: 37120..41215 0 (37120..41215) 4096 00011
5: [20480..24575]: 49408..53503 0 (49408..53503) 4096 00011
6: [24576..32767]: 57600..65791 0 (57600..65791) 8192 00011
7: [32768..36863]: 73984..78079 0 (73984..78079) 4096 00011
@keyurdg
keyurdg / mem.c
Created May 28, 2013 05:54
Allocate some memory
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv) {
size_t i = atoi(argv[1]) * sizeof(int);
int *ptr = malloc(i);
bzero(ptr, i);
fprintf(stdout, "Allocated %u bytes\n", i);
fflush(stdout);
@keyurdg
keyurdg / fopen.c
Created May 28, 2013 05:53
Create tons of dentry cache entries
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
int main(int argc, char **argv) {
char *prefix;
char *open_mode;
char filename[1024];
int i = 0;
@keyurdg
keyurdg / mysql_query_multiplexer.go
Created March 18, 2013 19:01
Read output from pt-query-digest and multiplex queries to MySQL over multiple threads.
package main
import (
"bufio"
"bytes"
_ "github.com/Go-SQL-Driver/MySQL"
"database/sql"
"flag"
"fmt"
"io"
@keyurdg
keyurdg / alter_generator.php
Created March 18, 2013 18:58
Generate ALTERs for all tables using MySQL's UTF8 character set. Also bump up any TEXT columns to LONGTEXT.
<?php
if (!isset($argv[1]) || strlen($argv[1]) < 1 ||
!isset($argv[2]) || strlen($argv[2]) < 1 ||
!isset($argv[3]) || strlen($argv[3]) < 1 ||
!isset($argv[4]) || strlen($argv[4]) < 1 ) {
echo "{$argv[0]} <hostname> <dbname> <login-name> <login-password> is the way to go!\n";
die();
}
diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4
index cdfa1f7..9a1b98d 100644
--- a/sapi/cli/config.m4
+++ b/sapi/cli/config.m4
@@ -6,6 +6,23 @@ PHP_ARG_ENABLE(cli,,
[ --disable-cli Disable building CLI version of PHP
(this forces --without-pear)], yes, no)
+AC_CHECK_FUNCS(setproctitle)
+