Skip to content

Instantly share code, notes, and snippets.

@joninvski
joninvski / bellman.py
Created November 16, 2010 11:31
Bellman ford python implementation
import pdb
"""
The Bellman-Ford algorithm
Graph API:
iter(graph) gives all nodes
iter(graph[u]) gives neighbours of u
graph[u][v] gives weight of edge (u, v)
"""
@koblas
koblas / smtp.py
Created November 11, 2011 15:23
SMTP Client for Tornado
from tornado import ioloop
from tornado import iostream
import socket
class Envelope(object):
def __init__(self, sender, rcpt, body, callback):
self.sender = sender
self.rcpt = rcpt[:]
self.body = body
self.callback = callback
@digitaljhelms
digitaljhelms / gist:4287848
Last active July 1, 2024 03:02
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@fmariluis
fmariluis / config.fish
Created August 22, 2013 19:05
Basic configuration for Fish Shell
set -xg PYTHONPATH /opt/eleccion/ $PYTHONPATH
set -xg PYTHONPATH /opt/operaciones/ $PYTHONPATH
set -xg GOROOT /usr/local/go $GOROOT
set -xg PATH /usr/local/go/bin $PATH
set -xg EDITOR vim $EDITOR
setenv EDITOR vim
function l
ll $argv
@sloria
sloria / bobp-python.md
Last active June 26, 2024 15:54
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@livibetter
livibetter / README.md
Last active June 25, 2018 05:00
Listing new trending repos on GitHub
@soheilhy
soheilhy / nginxproxy.md
Last active May 16, 2024 08:59
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@maartenbreddels
maartenbreddels / qt_and_tornado.py
Created October 1, 2015 10:57
Combining Qt and tornado, both which want to have their own event loop.
__author__ = 'breddels'
"""
Demonstrates combining Qt and tornado, both which want to have their own event loop.
The solution is to run tornado in a thread, the issue is that callbacks will then also be executed in this thread, and Qt doesn't like that.
To fix this, I show how to use execute the callback in the main thread, using a Qt signal/event in combination with Promises.
The output of the program is:
fetch page, we are in thread <_MainThread(MainThread, started 47200787479520)>
response is 191548 bytes, we are in thread <Thread(Thread-1, started daemon 47201018689280)>
the other thread should fulfil the result to this promise, we are in thread <Thread(Thread-1, started daemon 47201018689280)>
@joglomedia
joglomedia / mailwizz.dev.conf (MailWizz Nginx Configuration)
Last active November 9, 2022 22:17
MailWizz Nginx Configuration (Install using Simple LNMP Installer - https://github.com/joglomedia/deploy) - MailWizz EMA is a simple, efficient and full-featured email marketing application with an impressive features set. Download MailWizz here http://goo.gl/qDMd0I
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
## Make site accessible from world web.
server_name mailwizz.dev www.mailwizz.dev;
## Log Settings.
access_log /var/log/nginx/mailwizz.dev_access.log;
error_log /var/log/nginx/mailwizz.dev_error.log error;
@bhtucker
bhtucker / upsert.py
Last active April 3, 2024 15:56
A demonstration of Postgres upserts in SQLAlchemy
"""
Upsert gist
Requires at least postgres 9.5 and sqlalchemy 1.1
Initial state:
[]
Initial upsert: