Skip to content

Instantly share code, notes, and snippets.

View indradhanush's full-sized avatar
Out playing

Indradhanush Gupta indradhanush

Out playing
View GitHub Profile
@indradhanush
indradhanush / sync.py
Created June 16, 2014 08:05
Asynchronous request response
def get_sync_info(source_id):
"""
Gets the sync information.
"""
socket.send_multipart([req_type, source_id])
# Should return the response to the above request.
# Some callback should return the response probably.
return response
@indradhanush
indradhanush / term_vs_destroy.py
Created June 16, 2014 08:20
Reproducing blocking zmq.Context.term() vs Non blocking zmq.Context.destroy()
import zmq
# Server
class Server():
def __init__(self, context):
self.context = context
self.router = self.context.socket(zmq.ROUTER)
self.router.bind("tcp://127.0.0.1:9876")
@indradhanush
indradhanush / zmq_target.py
Created June 16, 2014 19:08
get_sync_info() in zmq
class ZMQSyncTarget(ZMQClientBase, SyncTarget):
def get_sync_info(self, source_replica_uid):
"""
Returns the sync state.
Note: Doesnt return anything now. BROKEN.
"""
str_msg = serialize_msg("SourceRequest",
source_replica_uid=source_replica_uid)
str_sync_type = serialize_msg("SyncType", sync_type="sync-from")
str_zmq_verb = serialize_msg("ZMQVerb", verb=proto.ZMQVerb.GET)
@indradhanush
indradhanush / sync.py
Last active August 29, 2015 14:05
Using mock
class ZMQSynchronizer(Synchronizer):
"""
Extends leap.soledad.client.sync.SoledadSynchronizer
"""
syncing_lock = Lock()
def _sync(self, autocreate=False, defer_decryption=True):
"""
Overrides SoledadSynchronizer._sync
"""
@indradhanush
indradhanush / gist:ba89e403650f2b9147ba
Last active August 29, 2015 14:05 — forked from mitchellh/gist:1277049
Fix for Internet connectivity issue on Vagrant + Ubuntu/Mint as host OS
Vagrant::Config.run do |config|
# ...
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
From 8ab91751069e391a95151c6716a546b1732ade92 Mon Sep 17 00:00:00 2001
From: JP <twitter:canoeberry>
Date: Sun, 19 Jan 2014 11:58:54 +0000
Subject: [PATCH] partial memleak fix
This patch was created by JP (twitter: @canoeberry) based on a memleak fix by Dirk (emacs committer) below:
https://github.com/mirrors/emacs/commit/57ae6509a3b6a274f89b9caea0284c6156470625
This memory leak is fixed in the trunk as of now and will be in the next official release: 24.4.
@indradhanush
indradhanush / gogozmq.go
Last active November 22, 2015 14:49
Attempt to get zmq handshake working
type Conn interface {
net.Conn
Connect(endpoint string) error
CurrentIdx() int
Serve() error
handleConnection(conn net.Conn) error
}
type Sock struct {
conns []net.Conn
@indradhanush
indradhanush / test_output
Last active November 22, 2015 14:47
Weird output for Pull sock.
// Run 1
dhanush@Indradhanushs-MacBook-Pro:~/golang/src/github.com/zeromq/gogozmq$ go test -v -run TestPullSockSingleConnection
=== RUN TestPullSockSingleConnection
got incoming &{{0xc8200bc000}}
--- PASS: TestPullSockSingleConnection (0.00s)
sock_test.go:46: new pull
sock_test.go:54: new push
sock_test.go:60: push hello
read bytes: 7
PASS
@indradhanush
indradhanush / service-checklist.md
Created September 20, 2016 11:41 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@indradhanush
indradhanush / rotate-aws-iam-keys.sh
Last active October 16, 2019 08:43
AWS Access Key rotation
#!/bin/bash
#
# This script rotates your aws access keys by creating
# a new one and deleting the older one.
# Requirements
# You must have a working aws cli configured already
# Run `aws configure` otherwise first before running this script.
# Installation & Usage