Skip to content

Instantly share code, notes, and snippets.

@hackjoy
hackjoy / deep_reverse.py
Created February 8, 2013 01:33
Reverse every element within a list including nested lists.
def is_list(p):
return isinstance(p, list)
def deep_reverse(p):
if is_list(p):
result = []
for i in range (len(p) - 1, -1, -1):
result.append(deep_reverse(p[i]))
return result
else:
@hackjoy
hackjoy / stirling_and_bell.py
Created February 8, 2013 02:05
Calculates the number of group combinations possible given a number n and a number of sets k.
def stirling(n, k):
if k > n:
return 0
elif k == n or k == 1:
return 1
else:
return (k*stirling(n-1, k) + stirling(n-1, k-1))
def bell(n):
bell = 0
@hackjoy
hackjoy / string_splitter.py
Created February 10, 2013 14:06
Split a string based on pre defined split characters
def split_string(source,splitlist):
output = []
atsplit = True
for char in source:
if char in splitlist:
atsplit = True
else:
if atsplit:
output.append(char)
atsplit = False
brew install elasticsearch
brew info elasticsearch
{
”ok” : true,
”status” : 200,
”name” : “Destroyer”,
”version” : {
”number” : “0.90.5″,
”build_hash” : “c8714e8e0620b62638f660f6144831792b9dedee”,
”build_timestamp” : “2013-09-17T12:50:20Z”,
”build_snapshot” : false,
”lucene_version” : “4.4″
{"ok":true,"acknowledged":true}
{
"badger": {
"properties": {
"name": {"type": "string"},
"role": {"type": "string"},
"bio": {"type": "string"}
}
}
}
{ "create" : { "_index" : "animal", "_type" : "badger", "_id" : "1" } }\n
{ "name" : "Cain Ullah", "role": "Founder", "bio": "Cain is a Founder of Red Badger, the non-techy responsible for business operations. He's worked on lots of innovative projects - from prototype to delivery - for some very big brands. He also likes to clog up the Red Badger mailroom with a constant influx of vinyl purchases to add to his ever-increasing collection." }\n
{ "create" : { "_index" : "animal", "_type" : "badger", "_id" : "2" } }\n
{ "name" : "David Wynne", "role": "Founder", "bio": "Founder, developer, and lover (not a hater). David has been making stuff work really well for over 14 years, five of those at Microsoft in the UK, USA and around Europe. He has lead teams, introduced agile into organisations and loves the detail. One day David will write a novel. A really long and interesting one." }\n
{ "create" : { "_index" : "animal", "_type" : "badger", "_id" : "3" } }\n
{ "name" : "Stuart Harris", "role": "Founder", "bio":
{{ipconfig}} localhost workspace.local
54.229.63.199 login.dev.local
54.229.64.203 workspace.dev.local
54.229.79.21 workspace1.dev.local
255.255.255.255 broadcasthost
@hackjoy
hackjoy / package.json
Last active December 31, 2015 23:09
[node npm] package.json
{
"name": "http-server",
"preferGlobal": true,
"version": "0.3.0",
"author": "Nodejitsu <support@nodejitsu.com>",
"description": "a simple zero-configuration command-line http server",
"contributors": [
{
"name": "Marak Squires",
"email": "marak@nodejitsu.com"