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 / count-commas.rb
Last active December 13, 2015 18:18
A copy of my count-commas.groovy gist in ruby. Count the number of commas in each line, as of check-in 2 supports _real_ quoted CSV, too.
#!/usr/bin/env ruby
require 'csv'
CSV.foreach(ARGV[0],'r') {|row| puts row.size}
@nicdoye
nicdoye / puma.sh
Created March 1, 2013 16:34
Simple startup file for individual [Puma](http://puma.io) apps on RHEL/CentOS (tested on 6.x). Just the bare minumum needed, really. Do not call it puma.sh but place a copy in for each of your puma applications. (It relies on its own name to work) By renaming it you can have as many different apps (on separate ports) as you require. You'll need …
#!/bin/sh
#
# Puma control script
#
# chkconfig: - 80 20
# description: Puma
# Create an /etc/sysconfig/file of the same name as this with the following settings
# Note this code does NOT pick any defaults, so will fall over if these are unset.
# RACK_ENV=production
@nicdoye
nicdoye / rhel6-32-bit-ruby-howto.md
Last active December 15, 2015 11:48
Compiling 32-bit ruby (MIR) on 64-bit RHEL 6

Building 32-bit ruby on 64-bit RHEL 6

Introduction

Will presumably work for many RHEL "derivatives", like CentOS, Oracle Enterprise Linux, Scientific Linux as well as "similar enough" versions of Fedora.

There is a use case for 32-bit ruby as set out in this G+ post

Set up yum

@nicdoye
nicdoye / Designer.cs
Created July 26, 2013 13:06
How to open BusinessObjects Designer XI R3.1 in C#. This is if you add Interop.DesignerX12 as a reference. If you use Interop.Designer, the package namespace is "Designer" not "DesignerX12".
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesignerTest
{
class Program
{
@nicdoye
nicdoye / mounts2monit.rb
Created August 30, 2013 14:45
Create basic monit config files from /proc/mounts
#!/usr/bin/env ruby
# Linux only, sorry.
#
# Look for ext[34], xfs and vxfs. Alter the regexp FILESYSTEMS for others
#
# If you have /root as a separate partition, alter the value of ROOT_USABLE
# Config
@nicdoye
nicdoye / fill_disk.sh
Created September 16, 2013 12:17
Gradually (nearly) fill a disk. Using it to test monit rules. Obviously on a real box, with other users, the disk could fill up. Caveat user.
#!/bin/bash
mountpoint=/tmp
sleeper=240
# percentage of disk used
function percentage { df $1 | tail -1 | awk '{print $4}' | tr -d % ; }
# Where we'll write
tempdir=$(mktemp -d --tmpdir=${mountpoint})
@nicdoye
nicdoye / csvwriter.groovy
Created November 29, 2013 17:52
Quick example of using Apache Commons CSV (1.0-Snapshot) to write to a CSV file in groovy.
import org.apache.commons.csv.CSVPrinter
import org.apache.commons.csv.CSVFormat
CSVPrinter printer = new CSVPrinter(
new PrintWriter("test.csv"),
CSVFormat.DEFAULT
)
answer = [ [5,6,"asdf",7],[9,10,"a b","z,x",12]]
@nicdoye
nicdoye / pidfile-checker.sh
Created June 27, 2014 16:50
Simple shell script for monit to check if a lock file (containing a pid) has been left hanging around for a process that is not a daemon.
#!/bin/bash
. /lib/lsb/init-functions
pidofproc "$@" &>> /dev/null
retval=$?
# Ignore cases such as retval=3 (Pid file doesn't exist)
if [ $retval -ne 1 ]
@nicdoye
nicdoye / perl-find.sh
Created October 3, 2015 13:24
Find all .pm files (in /usr/*/perl5)
#!/bin/bash
# I know it's a bit stupid and there's better ways to do it. But who doesn't like playing.
# Written for an old CentOS 4 server where people have installed Perl modules any old how.
# Is there a way to merge the two matches together?
find /usr/*/perl5 | ruby -ne '/^(\/\w+){4}\/.*\.pm/.match($_) && puts( /^(\/\w+){4}\/[\.\d]*\/{0,1}(.*)/.match($_)[2] )'
@nicdoye
nicdoye / 7z-release.sh
Created November 13, 2015 10:38
7zip but exclude .git (Simples, but I don't use it that often).
#!/bin/bash
7z a -x'!*/.git' $1.7z $1