Skip to content

Instantly share code, notes, and snippets.

from flask import Module, request, redirect, url_for, render_template, abort
from formalchemy import FieldSet
from example import db
from example import Service, User, Forum, Category, Topic, Post
mod = Module(__name__)
models = {
Code should be easy to write, and easy to read. You should be able to
keep it short and sweet, without repeating yourself. Tools are here to
help development, not hinder it.

finger_server.js

An extremely minimal implementation of the `Finger protocol`_ using node.js.

To run (Finger uses port 79 which requires sudo):

sudo node finger_server.js
import redis
from django.conf import settings
from django.core.signals import request_finished
try:
from eventlet.corolocal import local
except ImportError:
from threading import local
This setup is very ugly and will hopefully get better when some of the TODOs
for tmux get implemented.
---
1. Add the stuff from the vimrc file to your .vimrc or some file that is sorced
from your .vimrc.
- This just adds a few maps and functions to escape vim with ^w<motion>
when you are on an edge window in vim.
@kennethreitz
kennethreitz / virtualenvs.zsh
Created March 28, 2011 15:23
Automatic de/activating virtualenvs!
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/share/python//virtualenvwrapper.sh
export VIRTUALENV_USE_DISTRIBUTE="1"
function cd(){
builtin cd "$@"
$(/Users/kreitz/.oh-my-zsh/tools/workon.py)
}
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
@derekp7
derekp7 / gist:9978986
Last active May 11, 2024 04:10
RPC in Bash (rpcsh)

Let's say you have a Bash shell script, and you need to run a series of operations on another system (such as via ssh). There are a couple of ways to do this.

First, you can stage a child script on the remote system, then call it, passing along appropriate parameters. The problem with this is you will need to manually keep the remote script updated whenever you change it -- could be a bit of a challenge when you have something to execute on a number of remote servers (i.e., you have a backup script running on a central host, and it needs to put remote databases in hot backup mode before backing them up).

Another option is to embed the commands you want to run remotely within the ssh command line. But then you run into issues with escaping special characters, quoting, etc. This is ok if you only have a couple commands to run, but if it is a complex piece of Bash code, it can get a bit unwieldy.

So, to solve this, you can use a technique called rpcsh -- rpc in shell script, as follows:

First, place th