Skip to content

Instantly share code, notes, and snippets.

View nicdoye's full-sized avatar
🚲
All shall be well, and all shall be well, and all manner of thing shall be well

Nic Doye nicdoye

🚲
All shall be well, and all shall be well, and all manner of thing shall be well
View GitHub Profile
@nicdoye
nicdoye / gpsnmpd
Created January 9, 2013 16:17
Init script for Greenplum 4 SNMP subagent for RHEL 5 Fork it and fix it for SLES, RHEL 6. You could also get it to work with .pgpass (as mentioned in the admin guide - didn't work here, so I put them in the file).
#!/bin/sh
#
# gpsnmpd: Provides the Greenplum SNMP as a sub-agent
#
# chkconfig: 35 99 01
# description: gpsnmpd is the GP Software agent for SNMP
#
#
# Sanity checks.
@nicdoye
nicdoye / statsd
Created January 9, 2013 16:29
Init script for statsd that works om RHEL 6/CentOS 6
#! /bin/sh
### BEGIN INIT INFO
# Provides: statsd
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# Do NOT "set -e"
@nicdoye
nicdoye / activemq
Last active August 23, 2017 15:10
Init script for activemq. Known to work on RHEL 6, probably works on RHEL 5 and SLES Relies on variables set in /etc/sysconfig/activemq
#!/bin/bash
#
# activemq Starts ActiveMQ.
#
#
# chkconfig: 345 88 12
# description: ActiveMQ is a JMS Messaging Queue Server.
### BEGIN INIT INFO
# Provides: activemq
### END INIT INFO
@nicdoye
nicdoye / tomcat7
Created January 9, 2013 16:52
Very simple Init Script for Tomcat 7 (works for 6, too). Tested on RHEL 6. Should work on RHEL 5 and SLES, too. Relies on file /etc/sysconfig/tomcat7 which contains two variables RUN_AS_USER (who to run) and CATALINA_HOME. Everything else (JAVA_OPTS, CATALINA_OPTS, CATALINA_PID) is set in $CATALINA_HOME/bin/setenv.sh
#!/bin/bash
#
# Init file for Tomcat 7 server
#
# chkconfig: 2345 80 20
# description: Tomcat 7 server
#
# Source function library.
. /etc/init.d/functions
@nicdoye
nicdoye / getpid.c
Created January 21, 2013 11:16
Quick demo of getpid (and getppid)
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main ( int argc, char *argv[] )
{
pid_t p;
pid_t pp;
@nicdoye
nicdoye / inodes.c
Created January 28, 2013 10:55
List number of inodes for file system and how many spare.
#include <stdio.h>
#include <stdlib.h>
#include <sys/statvfs.h>
int main(int argc, char **argv)
{
struct statvfs _statvfs;
if ( argc != 2 )
@nicdoye
nicdoye / mallocer.c
Created January 28, 2013 11:02
Allocate RAM wait a minute and exit. Useful for flushing caches etc. Can chose between malloc and calloc.
/*
Program to allocate MB of memory. Can chose between calloc and malloc implementations.
Author: nic doye http://worldofnic.org
Date: 2011.03.31
Last update: 2012.10.16
*/
#include <stdlib.h>
@nicdoye
nicdoye / fstab
Created January 30, 2013 11:14
Sample /etc/fstab for cygwin
# First just shows how to mount a UNC path
# Second just puts Google Drive somewhere useful
//<servername>/<path> /mnt/<path> smbfs acl,binary,nouser,posix=1 0 0
C:/Users/<username>/Google\040Drive /mnt/google smbfs acl,binary,nouser,posix=1 0 0
@nicdoye
nicdoye / count-commas.groovy
Created January 31, 2013 16:21
Count the number of commas in each line. Useful for checking simple CSV (but not proper, quoted CSV).
#!/usr/bin/env groovy
new File( args[0] ).eachLine{ it -> println it.count(',') }
@nicdoye
nicdoye / mysqlbackup.sh
Created February 2, 2013 13:07
Backup your OpenShift MySQL database. My DB is only small so I didn't bother to compress it through a pipe. sftp it back from your local machine afterwards This is basically a quick hack from running "type mysql" on the OpenShift gear - hint: it's a bash function/alias
mkdir ~/app-root/data/tmp
mysqldump -h $OPENSHIFT_MYSQL_DB_HOST -P ${OPENSHIFT_MYSQL_DB_PORT:-3306} -u ${OPENSHIFT_MYSQL_DB_USERNAME:-'admin'} --password="$OPENSHIFT_MYSQL_DB_PASSWORD" --all-databases > ~/app-root/data/tmp//all.sql