Skip to content

Instantly share code, notes, and snippets.

View mneedham's full-sized avatar

Mark Needham mneedham

View GitHub Profile
@mneedham
mneedham / gist:6104020
Last active December 20, 2015 08:59
netcat UDP
# Start up netcat server
nc -kluv localhost 9000
# Check it with lsof
$ lsof -Pni :9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 59231 markneedham 5u IPv6 0xd2ab0eedfdf2c00b 0t0 UDP [::1]:9000
# Send a UDP packet and see it's received
$ echo -n "mark" | nc -vvu localhost 9000

A simple GraphGist

You create a GraphGist by creating a GitHub Gist in AsciiDoc and enter the URL to it in the form on this page.

Click on the Page Source button in the menu to see the source for this GraphGist!

Include a query console

//console

A simple GraphGist

You create a GraphGist by creating a GitHub Gist in AsciiDoc and enter the URL to it in the form on this page.

Click on the Page Source button in the menu to see the source for this GraphGist!

Include a query console

//console

A simple GraphGist

You create a GraphGist by creating a GitHub Gist in AsciiDoc and enter the URL to it in the form on this page.

Click on the Page Source button in the menu to see the source for this GraphGist!

Include a query console

//console

= How to create a GraphGist
You create a GraphGist by creating a https://gist.github.com/[GitHub Gist] in http://asciidoctor.org/docs/asciidoc-quick-reference/[AsciiDoc] and enter the URL to it in the form on this page.
Alternatively, you can put an AsciiDoc document in https://www.dropbox.com/[Dropbox] and enter the public URL in the form.
This GraphGist shows the basics of using AsciiDoc syntax and a few additions for GraphGists.
The additions are entered as comments on their own line.
They are: +//console+ for a query console; +//hide+, +//setup+ and +//output+ to configure a query; +//graph+ and +//table+ to visualize queries and show a result table.
Click on the Page Source button in the menu to see the source for this GraphGist.
import pandas as pd
fare_ceiling = 40
train_df = pd.read_csv('train.csv')
train_df[train_df['Fare'] >= 39.0] = 39.0
fare_bracket_size = 10
number_of_price_brackets = fare_ceiling / fare_bracket_size
number_of_classes = 3 #There were 1st, 2nd and 3rd classes on board
survival_table = pd.DataFrame(columns=['Sex', 'Pclass', 'PriceDist', 'Survived', 'NumberOfPeople'])
@mneedham
mneedham / pandas.py
Last active December 26, 2015 22:59
import pandas as pd
def addrow(df, row):
return df.append(pd.DataFrame(row), ignore_index=True)
def fare_in_bucket(fare, fare_bracket_size, bucket):
return (fare > bucket * fare_bracket_size) & (fare <= ((bucket+1) * fare_bracket_size))
def build_survival_table(training_file):
fare_ceiling = 40
#!/bin/sh
echo "i know spaces in the name are bad but the actual problem is the JRE 1.7 location on a Mac. JDK works fine"
library('RCurl')
library('RJSONIO')
query <- function(querystring) {
h = basicTextGatherer()
curlPerform(url="http://localhost:7474/db/data/cypher",
postfields=paste('query',curlEscape(querystring), sep='='),
writefunction = h$update,
verbose = FALSE
)
WITH me.name AS me, COLLECT(friend.name) AS friends
RETURN me, [HEAD(friends)] + [HEAD(TAIL(friends))] + [HEAD(TAIL(TAIL(friends)))] + [HEAD(TAIL(TAIL(TAIL(friends))))] + [HEAD(TAIL(TAIL(TAIL(TAIL(friends)))))]