Skip to content

Instantly share code, notes, and snippets.

View saghul's full-sized avatar

Saúl Ibarra Corretgé saghul

View GitHub Profile
var
PARALLEL_CONNECTS = 10,
http = require('http'),
sys = require('sys'),
connectionCount = 0,
messageCount = 0;
lastMessages = 0;
function addClient() {
@weaver
weaver / starttls.py
Created February 3, 2010 07:40
Example of STARTTLS with Tornado
"""starttls -- an example of wrapping a non-blocking socket with TLS.
Example:
> openssl req -new -x509 -days 365 -nodes -out /tmp/cert.crt -keyout /tmp/cert.key
> python /path/to/this-file.py
starting client: 7
starting server: 8
client said: 'hello'.
server said: "YOU SAID: 'hello'".
@mislav
mislav / pagination.md
Created October 12, 2010 17:20
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@maxcountryman
maxcountryman / kaa.py
Created November 15, 2010 01:35
A very simple non-blocking IRC bot using gevent
import gevent
from gevent import socket, queue
from gevent.ssl import wrap_socket
import logging
logger = logging.getLogger('irc')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
@alanfranz
alanfranz / idea.desktop
Created February 3, 2011 16:32
Pycharm Desktop Entry
[Desktop Entry]
Encoding=UTF-8
Name=IDEA
Exec=PATH_TO_IDEA_DIR/bin/idea.sh
Icon=PATH_TO_IDEA_DIR/bin/idea_CE128.png
Type=Application
Categories=Development;
StartupWMClass=IDEA
@EnigmaCurry
EnigmaCurry / ipython_virtualenv.py
Created February 9, 2011 01:52
Setup ipython to work in a virtualenv
#Call this inside ~/.ipython/ipy_user_conf.py main()
import sys
import subprocess
from os import environ
if 'VIRTUAL_ENV' in environ:
#This is kludgy but it works; grab the right sys.path from the virtualenv python install:
path = subprocess.Popen(['python', '-c','import sys;print(repr(sys.path))'],
stdout=subprocess.PIPE).communicate()[0]
@stefanfoulis
stefanfoulis / osx_developer_installation.rst
Last active June 17, 2024 17:46
Instructions on how to setup an OSX developer machine for (python/django) development

OSX Developer System installation

This guide assumes a fresh install of Mac OSX 10.7 Lion.

Brew User

@nitrogenlogic
nitrogenlogic / 00_popen3_moved.md
Last active May 29, 2019 11:53
Two implementations of a popen3() function in POSIX/C providing stdin, stdout, and stderr
@pcardune
pcardune / .gitignore
Created September 5, 2011 04:55
Facebook command-line client helper
.fb_access_token
.fbconsole.py
@chrisroos
chrisroos / gpg-import-and-export-instructions.md
Created September 9, 2011 10:49
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...