This is a simple chat-like program using pub-sub pattern, backed by PostgreSQL's LISTEN/NOTIFY command.
publish message to foo channel from user nickname.
$ python pub.py foo nickname
PUBLISH to channel #foo
| import os, os.path, sys, urllib2, requests | |
| class PyPiError(Exception): | |
| def __init__(self, value): | |
| self.value = value | |
| def __str__(self): | |
| return repr(self.value) | |
| def _chunk_report(bytes_so_far, chunk_size, total_size): | |
| if (total_size != None): |
| #this script can never fail | |
| #i use it in the fish_config | |
| #call it with start_agent | |
| setenv SSH_ENV $HOME/.ssh/environment | |
| function start_agent | |
| if [ -n "$SSH_AGENT_PID" ] | |
| ps -ef | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null |
I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)
| # -*- coding: utf-8 -*- | |
| # In order to run this script, you'll need to | |
| # have both py.test and six installed. | |
| # Assuming you have pip, in a virtualenv just | |
| # type at the command-line: | |
| # | |
| # pip install pytest six | |
| # | |
| # To run it, just type: | |
| # |
| import json | |
| import geojson | |
| from shapely.geometry import shape | |
| o = { | |
| "coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]], | |
| "type": "Polygon" | |
| } | |
| s = json.dumps(o) |
Magic words:
psql -U postgresSome interesting flags (to see all, use -h or --help depending on your psql version):
-E: will describe the underlaying queries of the \ commands (cool for learning!)-l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)| # IMPORTANT SETUP INSTRUCTIONS: | |
| # | |
| # 1. Go to http://www.dropbox.com/developers/apps (log in if necessary) | |
| # 2. Select "Create App" | |
| # 3. Select the following settings: | |
| # * "Dropbox API app" | |
| # * "Files and datastores" | |
| # * "(No) My app needs access to files already on Dropbox" | |
| # * "All file types" | |
| # * (Choose any app name) |
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev