Skip to content

Instantly share code, notes, and snippets.

View johanmeiring's full-sized avatar

Johan Meiring johanmeiring

View GitHub Profile
@johanmeiring
johanmeiring / gist:2894568
Created June 8, 2012 08:52
PHP str_putcsv function
<?php
/* From: http://www.php.net/manual/en/function.str-getcsv.php#88773 and http://www.php.net/manual/en/function.str-getcsv.php#91170 */
if(!function_exists('str_putcsv'))
{
function str_putcsv($input, $delimiter = ',', $enclosure = '"')
{
// Open a memory "file" for read/write...
$fp = fopen('php://temp', 'r+');
// ... write the $input array to the "file" using fputcsv()...
fputcsv($fp, $input, $delimiter, $enclosure);
@johanmeiring
johanmeiring / checkSpace.sh
Last active October 2, 2015 02:58
Linux disk space checker
#!/bin/bash
# Disk space checking script.
# Version 0.2
# All of the below parameters can be overriden via command line arguments.
# Minimum disk space that should be available, in kilobytes.
THRESHOLD=20971520
# Partition/Filesystem that we should check.
PARTITION="/dev/md1"
# Email address that mail should be sent to.
@johanmeiring
johanmeiring / .bashrc
Last active October 2, 2015 02:58
Colour *nix prompt with git status
# Ubuntu / Debian:
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]`[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "\[\e[31m\]" || echo "\[\e[32m\]"`$(__git_ps1 " (%s)\[\e[00m\]") \[\e[00m\]\$ '
# OSX:
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]`[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "\[\e[31m\]" || echo "\[\e[32m\]"`$(__git_ps1 " (%s)\[\e[00m\]") \[\e[00m\]\$ '