Skip to content

Instantly share code, notes, and snippets.

View dblalock's full-sized avatar

dblalock

View GitHub Profile
#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;
@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
@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 / 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 / svnDeleteMissingFiles.sh
Created July 18, 2014 19:48
svn delete missing files
svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )
# note that this won't work if there's whitespace in the filenames
# http://stackoverflow.com/a/9600437/1153180
@dblalock
dblalock / selected_msgs_to_urls.scpt
Created September 5, 2016 03:20
Creates markdown links to the currently selected Apple Mail messages and copies them to the clipboard
--E.g., if you have a message selected that has subject and body:
-- Subj: Meeting about the Foo!
-- Body: whatever
--Running this script copies to the clipboard the string:
-- [Meeting about the Foo!](message://<some message id>)
--If you click on the resulting url, the message opens in Mail
--
--Basically, this is for getting links to emails into a todo list / task manager
--based on https://www.macstories.net/tutorials/send-selected-mail-message-to-evernote-with-source-url/
@dblalock
dblalock / align.c
Created August 30, 2017 22:11
C / C++ portable aligned memory allocation
/* Allocate aligned memory in a portable way.
*
* Memory allocated with aligned alloc *MUST* be freed using aligned_free.
*
* @param alignment The number of bytes to which memory must be aligned. This
* value *must* be <= 255.
* @param bytes The number of bytes to allocate.
* @param zero If true, the returned memory will be zeroed. If false, the
* contents of the returned memory are undefined.
* @returns A pointer to `size` bytes of memory, aligned to an `alignment`-byte
@dblalock
dblalock / pyience.py
Created September 4, 2017 22:33
Tools for running experiments
#!/bin/env/python
"""utility functions for running experiments"""
import datetime
import os
import itertools
import warnings
import numpy as np

Keybase proof

I hereby claim:

  • I am dblalock on github.
  • I am dblalock (https://keybase.io/dblalock) on keybase.
  • I have a public key ASArwQtIhdozJpppmdhAOiJHgd-DmtilH9vzvxNo_0vazQo

To claim this, I am signing this object: