Skip to content

Instantly share code, notes, and snippets.

Working from home


Working from home
View GitHub Profile
lettre_morse = {
"a": ".-",
"b": "-...",
"c": "-.-.",
"d": "-..",
"e": ".",
"f": "..-.",
"g": "--.",
"h": "....",
"i": "..",
Natim /
Last active Aug 29, 2015
How to handle our permission schema with Redis
# -*- coding: utf-8 -*-
from __future__ import print_function
import json
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=1)
# List of permissions that gives us this permission
'bucket:write': {
View client.js
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
//var testMessage = "[hello world] pid: " +;
var message = new Buffer([0x65,
'I', 'P', 'A', 'D', 0x00,
'N','A', 'M', 'E', 0x00,
'J', 'S', 'O', 'N', 0x00,
'V', 'E', 'R', 'S', 0x00,
'U', 'U', 'I', 'D', 0x00,

Keybase proof

I hereby claim:

  • I am Natim on github.
  • I am natim ( on keybase.
  • I have a public key whose fingerprint is 6EE7 90DE 2D5B 88AA F079 11BC A500 E24B 9540 5094

To claim this, I am signing this object:

Natim /
Created Feb 2, 2015
How to get an Oauth token for an client side app?

One of the problem when doing full HTML5 apps is the Authentication.

With Firefox Account, the OAuth dance implies a server. Here are some tips that we are using to provide the Oauth token to the client app after the Oauth dance.

  1. First add a button to the login page: GET /fxa-oauth/login?redirect=https://web-ui/#login-cb
  2. When the user clicks it will do the oauth-dance and come back to your redirect endpoint.
  3. At this time just GET /fxa-oauth/token to get the user oauth-token.
Natim / index.js
Created Nov 26, 2014
FxA auth dance with Daybed
View index.js
function startFxAOauthDance(host, options) {
if (host === undefined) {
throw new Error("You should provide a host.");
if (options === undefined || options.redirect_uri === undefined) {
throw new Error("You should provide a options.redirect_uri parameter.");
return request({
"""Delete all your couchdb database matching a pattern."""
import requests
import urllib
for db in requests.get("http://localhost:5984/_all_dbs").json():
print db,
if db.startswith("couchdb"):
print "DELETE",
r = requests.delete("http://localhost:5984/%s" % urllib.quote_plus(db))
Natim /
Created Sep 22, 2014
Python3 version of Boom
import asyncio
import aiohttp
def fetch_page(url, idx, num):
# Num per client
for i in range(num):
response = yield from aiohttp.request('GET', url)
if response.status == 200:
Natim / README.rst
Created Aug 25, 2014
Use a DNS TXT entry to configure a ramp up number for a slow software activation
View README.rst

Ramp Up

The problem

The idea of the ramp up is to have a scalable way to activate a software feature slowly so that the scale is handled.

If you have let say 10 million users and you want to launch a most wanted feature.

import asyncio.subprocess
def demo():
proc = yield from asyncio.create_subprocess_exec('ls', '-1', stdout=asyncio.subprocess.PIPE)
while True:
line = yield from proc.stdout.readline()
if not line:
You can’t perform that action at this time.