Skip to content

Instantly share code, notes, and snippets.

@lyndsysimon
lyndsysimon / gist:96977376ff5a743b737a3a30b607e6c8
Last active September 29, 2016 18:04
Python functional composition
class composable:
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
def __or__(self, other):
return lambda *args, **kwargs: self(other(*args, **kwargs))
@lyndsysimon
lyndsysimon / account_merge.py
Created April 22, 2015 16:27
OSF fixture generator
from tests import factories
from website import models
from website.util import web_url_for
from main import app
def print_merge_url(user, token, prefix):
with app.test_request_context():
print(prefix + ": " +
web_url_for(
'confirm_email_get',
@lyndsysimon
lyndsysimon / temp.json
Last active August 29, 2015 14:02
temp
{
"tasks": [
{ "id": 1, "text": "my text 1" },
{ "id": 2, "text": "my text 2" },
{ "id": 3, "text": "my text 3" },
{ "id": 4, "text": "my text 4" }
]
}
alert('foo');
@lyndsysimon
lyndsysimon / tasks.md
Last active August 29, 2015 14:01
COS Intern Tasks
@lyndsysimon
lyndsysimon / mantras.md
Last active August 29, 2015 14:01
Lyndsy's Development Mantras
  • There once was a developer who had a problem. They decided to solve this problem using a regex. That developer now has two problems.

  • All problems in computer science can be solved through additional layers of abstraction.

@lyndsysimon
lyndsysimon / templating_language_concept
Last active December 20, 2015 21:08
A quick concept of a pythonic templating language based on Zen Coding, with inspiration from HAML and SASS.
#### Template (proposed, unnamed language)
doctype(5)
html>head
style('my_stylesheet.css')
script('my_script.js')
title= {{ title }}
body>div.container
navbar(main_menu_links)

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems