Skip to content

Instantly share code, notes, and snippets.

@alexclare
alexclare / gist:3410169
Created August 21, 2012 01:04
Hacky IRCCloud ping script
import json, pycurl, subprocess, urllib, urllib2
def session_cookie(email, pw):
'''Small helper to grab the session ID if necessary.
You don't need to do this often; session IDs don't expire frequently.
'''
req = urllib2.Request(
url='https://irccloud.com/chat/login',
data=urllib.urlencode([('email', email), ('password', pw)]))
res = urllib2.urlopen(req)

Keybase proof

I hereby claim:

  • I am alexclare on github.
  • I am alexclare (https://keybase.io/alexclare) on keybase.
  • I have a public key whose fingerprint is 9E69 7FA4 8069 CACE 2E84 C381 A706 3F10 D905 E5D4

To claim this, I am signing this object:

@alexclare
alexclare / common.py
Created March 16, 2015 15:38
common.py
'common, fun python functions that I seem to rewrite everywhere'
import itertools, sys
# stolen from itertools recipes
def chunk(iterable, batch_size, fillvalue=None):
'breaks up iterator into chunks of batch_size'
args = [iter(iterable)] * batch_size
return itertools.izip_longest(fillvalue=fillvalue, *args)
@alexclare
alexclare / health.json
Last active January 11, 2017 07:35
pro json
{
"cluster_name": "elasticsearch",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 5,
"active_shards": 5,
"relocating_shards": 0,
"initializing_shards": 0,

find the type of these expressions!
  expression
response["timed_out"]
response["hits"]
response["hits"]["total"]
response["hits"]["hits"]
response["hits"]["hits"][0]
response["hits"]["hits"][0]["_score"]