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 / count-commas.rb
Last active Dec 13, 2015
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.
View count-commas.rb
#!/usr/bin/env ruby
require 'csv'
CSV.foreach(ARGV[0],'r') {|row| puts row.size}
@nicdoye
nicdoye / puma.sh
Created Mar 1, 2013
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 …
View puma.sh
#!/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 Dec 15, 2015
Compiling 32-bit ruby (MIR) on 64-bit RHEL 6
View rhel6-32-bit-ruby-howto.md

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 Jul 26, 2013
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".
View Designer.cs
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 Aug 30, 2013
Create basic monit config files from /proc/mounts
View mounts2monit.rb
#!/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 Sep 16, 2013
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.
View fill_disk.sh
#!/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 Nov 29, 2013
Quick example of using Apache Commons CSV (1.0-Snapshot) to write to a CSV file in groovy.
View csvwriter.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 Jun 27, 2014
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.
View pidfile-checker.sh
#!/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 Oct 3, 2015
Find all .pm files (in /usr/*/perl5)
View perl-find.sh
#!/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 Nov 13, 2015
7zip but exclude .git (Simples, but I don't use it that often).
View 7z-release.sh
#!/bin/bash
7z a -x'!*/.git' $1.7z $1
You can’t perform that action at this time.