Skip to content

Instantly share code, notes, and snippets.

View evansde77's full-sized avatar

Dave Evans evansde77

View GitHub Profile
@evansde77
evansde77 / setup.sh
Last active December 5, 2016 23:19
Python Environment Setup on MacOSX
#!/bin/bash
# assumes that XCode and XCode command line tools have been installed
# xcode-select --install
# assumes that gfortran has been installed
# https://gcc.gnu.org/wiki/GFortranBinaries
# install pyenv & set 2.7.11 as current
# See: https://github.com/yyuu/pyenv-installer
# See: https://github.com/yyuu/pyenv
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
@evansde77
evansde77 / install_pillow.sh
Created June 8, 2016 15:40
Steps to install libjpeg and pillow on Max OSX 10.11.15 (assumes XCode, XCode command line tools etc)
sudo chmod -R a+rw /usr/local/src
mkdir /usr/local/src
chmod a+rw -R /usr/local/src
curl --remote-name http://www.ijg.org/files/jpegsrc.v9b.tar.gz
tar -xzvf jpegsrc.v9b.tar.gz
cd jpeg-9b
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a
@evansde77
evansde77 / word_count_histogram.py
Last active February 10, 2021 12:14
Playing around with an ascii histogram example
#!/usr/bin/env python
"""
Example wordcount and ascii histogram script
- Writes a data file in a temporary dir
- defines function to parse file into a word iterable
- Histogram class that does the word count and draws it as
ascii strings with various sorting options
Example usage:
@evansde77
evansde77 / pyfile_to_module.py
Last active May 26, 2016 18:11
Util to convert filenames to python module names as a command line tool
#!/usr/bin/env python
"""
pyfile_to_module
Simple util to convert a python filename like
some_package/some_module/some_file.py to some_package.some_module.some_file
style module name.
"""
import argparse
def post(self):
"""
Create a new user document in the users and cluster users database.
:json string username: required, the requested username
:json string password: required, the requested password
:json string email: required, and email address to be associated
with the account
:json string first_name: required, the user's first name
:json string last_name: required, the user's last name
:json string company: optional, the user's company
@evansde77
evansde77 / pythonic_config.py
Created February 12, 2016 17:10
Example of wrapping a nested JSON config object in a simple python object that allows dynamic object.attr style access to the data elements
#!/usr/bin/env python
"""
example of using a simple python object to wrap a JSON
configuration mapping so that it can be accessed as
a python style object using conf.attr1.attr2.value
"""
CONF = {
"CREDENTIALS": {
==> derp: Loading Berkshelf datafile...
==> derp: Sharing cookbooks with VM
==> derp: Updating Vagrant's Berkshelf...
==> derp: Resolving cookbook dependencies...
==> derp: Fetching 'derp' from source at .
==> derp: Fetching 'docker' from source at docker
==> derp: Using apt (2.9.2)
==> derp: Using build-essential (2.2.4)
==> derp: Using chef-sugar (3.3.0)
==> derp: Using compat_resource (12.5.26)
@evansde77
evansde77 / Vagrantfile
Last active January 29, 2016 23:15
Details for reproducing error in docker cookbook dependency under Vagrant/Chef-solo
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = '2'
Vagrant.require_version '>= 1.5.0'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
class MyTest(unittest.TestCase):
harness, setUp, tearDown = make_database_test_harness(**args)
def test_a_thing(self):
print self.harness