Skip to content

Instantly share code, notes, and snippets.

if CONF.has_key?("mounts")
for folder in CONF['mounts']
config.vm.share_folder(folder['name'], folder['virtual'], folder['host'], :nfs => true)
end
end
require "yaml"
# Load up our vagrant config files -- vagrantconfig.yaml first
_config = YAML.load(File.open(File.join(File.dirname(__FILE__),
"vagrantconfig.yaml"), File::RDONLY).read)
# Local-specific/not-git-managed config -- vagrantconfig_local.yaml
begin
_config.merge!(YAML.load(File.open(File.join(File.dirname(__FILE__),
"vagrantconfig_local.yaml"), File::RDONLY).read))
@bennylope
bennylope / list_filter.py
Created November 16, 2012 16:33
Simplified filtering without validation
class MyListView(ListView):
def get(self, request, *args, **kwargs):
self.object_list = self.get_queryset()
search_query = request.GET.get('search_query')
if search_query:
self.object_list = self.object_list.filter(name=search_query)
context = self.get_context_data(object_list=self.object_list)
return self.render_to_response(context)

Keybase proof

I hereby claim:

  • I am bennylope on github.
  • I am bennylope (https://keybase.io/bennylope) on keybase.
  • I have a public key whose fingerprint is 515A 85FE D3A7 9935 5E9E 2F6C CA23 6BC4 054B 7C47

To claim this, I am signing this object:

@bennylope
bennylope / todo.hs
Created December 10, 2015 19:20
Vaguely terrible Haskell
-- from http://www.haskellforall.com/2015/10/basic-haskell-examples.html
import System.Directory
import System.Environment
import System.IO
putTodo :: (Int, String) -> IO ()
putTodo (n, todo) = putStrLn (show n ++ ": " ++ todo)
prompt :: [String] -> IO ()
prompt todos = do
@bennylope
bennylope / commandments.md
Last active December 14, 2015 02:38
Commandments for Collaborative Programming: Coding and VCS workflow.
  1. Thou shalt make diffs meaningful
  2. Thou shalt meaningfully order merged commits
  3. Thou shalt not include superfluous merge commits
  4. Thou shalt make meaningful, well formatted commit messages
  5. Thou shalt only branch off of the canonical branch
  6. Thou shalt run tests before merging or issuing a pull request
  7. Thou shalt add tests for new code before merging or issuing a pull request
  8. Thou shalt not hard code settings, URL schemes, or app-domains
  9. Thou shalt follow a consistent project coding style
@bennylope
bennylope / README.md
Created February 27, 2013 19:21
Vagrant file setup (basic)

File structure

  • Vagrantfile - primary configuration
  • vagrantconfig.yaml - default configuration
  • vagrantconfig_local.yaml - local configuration, this file never gets checked into source control

Setup

The primary Vagrantfile is set up to use Ubuntu 12.04 LTS (Precise) and Puppet configuration has been commented out.

import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
@bennylope
bennylope / wpversions.py
Created March 25, 2013 17:09
Queries a list of WordPress installations for the version as found in the <meta name='generator'> tag.
import csv
import requests
from bs4 import BeautifulSoup
def is_generator(tag):
return True if tag.attrs.get('name', '') == 'generator' else False
@bennylope
bennylope / simple_scraper.py
Created May 9, 2013 20:13
Super simple scraper that uses `requests` to fetch a single page and then uses BeautifulSoup to parse the meta description.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import requests
from bs4 import BeautifulSoup
url = "http://www.wellfireinteractive.com"