Skip to content

Instantly share code, notes, and snippets.

"""
Sorting nodes of a graph according to their degrees
Idea from: http://mail.python.org/pipermail/python-list/2002-July/152876.html
"""
#example adjacency list
adjlist = {'a':['b','c','d'],'b':['a','d'],'c':['a'],'d':['b','a']}
histogram = [ (len(value), key) for key, value in adjlist.iteritems() ]
histogram.sort()
"""
This script writes the VDSO to the file linux-gate.dso.1 .
Use `objdump -d linux-gate.dso.1` to examine it.
You might also want to play around more with the other objdump options and
the readelf tool :)
LICENSE: MIT License ( http://www.opensource.org/licenses/mit-license.php )
"""
from __future__ import with_statement
import os
@anomit
anomit / app mailers queue_deliver_mailer.rb
Last active August 29, 2015 13:59
Hacking Rails mail delivery for an async solution with Sidekiq, Redis, Local Postfix SMTP server
class QueueDeliveryMailer < ActionMailer::Base
self.delivery_method = Rails.application.config.mail_queue_outbound_delivery_method #remember this from development.rb
layout nil
def rebuild_mail(id)
mail({:from => $redis.get("mail:#{id}:sender_address"),
:to => $redis.get("mail:#{id}:recipient_address"),
:reply_to => $redis.get("mail:#{id}:reply_to_address"),
:mime_version => $redis.get("mail:#{id}:mime_version"),
:content_type => $redis.get("mail:#{id}:content_type"),
import websockets
import asyncio
import json
import async_timeout
import sys
async def consumer_contract(retries_before_quitting=10):
counter = 0
async with websockets.connect(sys.argv[1]) as ws: