Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲
Tant que je respire, j’attaque

Nic Doye nicdoye

🚲
Tant que je respire, j’attaque
View GitHub Profile
@nicdoye
nicdoye / gpsnmpd
Created Jan 9, 2013
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).
View gpsnmpd
#!/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 Jan 9, 2013
Init script for statsd that works om RHEL 6/CentOS 6
View statsd
#! /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 Aug 23, 2017
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
View 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 Jan 9, 2013
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
View tomcat7
#!/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 Jan 21, 2013
Quick demo of getpid (and getppid)
View getpid.c
#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 Jan 28, 2013
List number of inodes for file system and how many spare.
View inodes.c
#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 Jan 28, 2013
Allocate RAM wait a minute and exit. Useful for flushing caches etc. Can chose between malloc and calloc.
View mallocer.c
/*
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 Jan 30, 2013
Sample /etc/fstab for cygwin
View fstab
# 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 Jan 31, 2013
Count the number of commas in each line. Useful for checking simple CSV (but not proper, quoted CSV).
View count-commas.groovy
#!/usr/bin/env groovy
new File( args[0] ).eachLine{ it -> println it.count(',') }
@nicdoye
nicdoye / mysqlbackup.sh
Created Feb 2, 2013
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
View mysqlbackup.sh
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
You can’t perform that action at this time.