Skip to content

Instantly share code, notes, and snippets.

View dblalock's full-sized avatar

dblalock

View GitHub Profile
@dblalock
dblalock / removeIfExists.sh
Last active August 29, 2015 14:04
Bash remove file if exists
function removeIfExists {
if [ -e "$1" ]; then
echo removing "$1"
rm -rf "$1" 2>&1 > /dev/null
fi
}
@dblalock
dblalock / gist:93a98b481e16baeea2be
Created July 11, 2014 18:21
C++ formatted width output stream
class formatted_output
{
private:
int width;
ostream& stream_obj;
public:
formatted_output(ostream& obj, int w): width(w), stream_obj(obj) {}
template<typename T>
@dblalock
dblalock / gist:5487534456ce1a35cf65
Created July 9, 2014 22:38
Bash include another file
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${DIR}/myFileToInclude.sh"
source "${DIR}/myOtherFileToInclude.sh"
# see http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
#include <stdio.h>
#include <stdlib.h>
#include "vector.h"
void vector_init(vector *v)
{
v->data = NULL;
v->size = 0;
v->count = 0;
#include <stdio.h>
#include <stdlib.h>
#include "vector.h"
void vector_init(vector *v)
{
v->data = NULL;
v->size = 0;
v->count = 0;