Skip to content

Instantly share code, notes, and snippets.

View jacobsvante's full-sized avatar

Jacob Magnusson jacobsvante

  • Hyperkliv AB
  • Hestra, Sweden
  • 05:39 (UTC +02:00)
View GitHub Profile
@jacobsvante
jacobsvante / README.md
Last active August 29, 2015 14:27 — forked from inklesspen/README.md
Fast and flexible unit tests with live Postgres databases and fixtures

(This gist is pretty old; I've written up my current approach to the Pyramid integration on this blog post, but that blog post doesn't go into the transactional management, so you may still find this useful.)

Fast and flexible unit tests with live Postgres databases and fixtures

I've created a Pyramid scaffold which integrates Alembic, a migration tool, with the standard SQLAlchemy scaffold. (It also configures the Mako template system, because I prefer Mako.)

I am also using PostgreSQL for my database. PostgreSQL supports nested transactions. This means I can setup the tables at the beginning of the test session, then start a transaction before each test happens and roll it back after the test; in turn, this means my tests operate in the same environment I expect to use in production, but they are also fast.

I based my approach on [sontek's blog post](http://sontek.net/blog/

@jacobsvante
jacobsvante / README.md
Last active June 30, 2020 01:54 — forked from agnoster/README.md
My version of the Agnoster theme, with Virtualenv support

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

<html>
<!--
This is an example of how to make browsers
offer to remember password and later fill in those passwords
for dynamic login forms.
To make the browser offer to remember passwords the form should be actually submitted.
Since we are handling login with AJAX we don't want the form to submit, so we are still submitting it
into a dummmy iframe with dummy URL.
It's good idea to actually create empty dummy.html file, otherwise you'll flood you error.log with 404s