Skip to content

Instantly share code, notes, and snippets.

View reidransom's full-sized avatar

Reid Ransom reidransom

View GitHub Profile
@reidransom
reidransom / views.py
Last active June 27, 2022 16:03
Returning binary data from a Django view
from django.http import HttpResponse
def django_file_download_view(request):
filepath = '/path/to/file.xlsx'
with open(filepath, 'r') as fp:
data = fp.read()
filename = 'some-filename.xlsx'
response = HttpResponse(mimetype="application/ms-excel")
response['Content-Disposition'] = 'attachment; filename=%s' % filename # force browser to download file
response.write(data)
# localhost:3000
NoMethodError in Home#index
Showing /Users/editor/Dropbox/www.b2plus.tv/app/views/home/index.html.slim where line #2 raised:
undefined method `poster' for nil:NilClass
Extracted source (around line #2):
@reidransom
reidransom / gist:7000836
Created October 16, 2013 00:32
Convert svg to png with the CLI
/Applications/Inkscape.app/Contents/Resources/bin/inkscape image.svg --export-png=image.png

A simple objective-c program

#import <Foundation/foundation.h>

int main( int argc, const char* argv[]) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSObject *object = [[NSObject alloc] init];
    NSLog(@"Created Object: %@", object);
    [pool release];

return 0;

@reidransom
reidransom / gist:6198304
Created August 9, 2013 23:59
Execute a command for each file in a folder

Execute a command for each file in a folder

$ for f in *.xls ; do xls2csv "$f" "${f%.xls}.csv" ; done

@reidransom
reidransom / gist:6167543
Last active December 8, 2022 05:50
HandBrakeCLI encoding for HTML5 Video

HandBrakeCLI --input 88Min_20_v2.mov --output 88Min_20_v2-handbrake.mp4 --large-file --optimize --encoder x264 --x264-preset medium --x264-profile high --x264-tune zerolatency --encopts level=3.1:vbv-bufsize=17500:vbv-maxrate=17500 --quality 22 --width 960 --height 540 --pixel-aspect 1:1 --decomb

@reidransom
reidransom / gist:6086313
Last active December 20, 2015 06:29
Create an empty file in OS X

Create an empty file in OS X

$ mkfile 1m onemegfile.txt

@reidransom
reidransom / gist:6042016
Created July 19, 2013 20:13
Auto-starting VirtualBox VMs on OS X

Auto-starting VirtualBox VMs on OS X

After finding a lot of other posts on the topic that didn't work out for me this one did the trick so I'm reposting for my own sense of self preservation.

Link to original article.

Copy the Virtualbox autostart plist template file to your system's LaunchDaemons folder.

sudo cp \

/Applications/VirtualBox.app/Contents/MacOS/org.virtualbox.vboxautostart.plist \

@reidransom
reidransom / gist:6033227
Last active April 4, 2024 14:31
Configure Zeroconf on FreeBSD

Configure Zeroconf on FreeBSD

Install avahi-app and nss_mdns. Note: avahi-app is chosen over avahi because avahi depends on X11.

$ cd /usr/ports/net/avahi-app
$ sudo make config-recursive
$ sudo make install clean
$ cd /usr/ports/dns/nss_mdns
$ sudo make config-recursive

$ sudo make install clean

@reidransom
reidransom / gist:6011044
Last active December 19, 2015 20:08
Configure manual ip on freebsd

Configure manual ip on FreeBSD

Add these lines to your /etc/rc.conf

ifconfig_em0="inet 192.168.0.10 netmask 255.255.255.0"
defaultrouter="192.168.0.1"
hostname="hostname.domain.com"

You may need to run ifconfig to get the name of your network interface like this: