Skip to content

Instantly share code, notes, and snippets.

View jfriedly's full-sized avatar

Joel Friedly jfriedly

View GitHub Profile
@jfriedly
jfriedly / gist:5732940
Created June 7, 2013 22:47
ceph osd dump
$ ceph osd dump
epoch 122
fsid 8708952c-1017-4bca-a764-14fcb6182e4a
created 2013-06-04 00:30:39.089586
modified 2013-06-07 20:59:00.593535
flags
pool 0 'data' rep size 2 min_size 1 crush_ruleset 0 object_hash rjenkins pg_num 64 pgp_num 64 last_change 1 owner 0 crash_replay_interval 45
pool 1 'metadata' rep size 2 min_size 1 crush_ruleset 1 object_hash rjenkins pg_num 64 pgp_num 64 last_change 1 owner 0
@jfriedly
jfriedly / radosgw.log
Created June 7, 2013 21:41
RADOS Gateway Logs
2013-06-07 21:06:11.442571 7fef2a085780 0 ceph version 0.61.2 (fea782543a844bb277ae94d3391788b76c5bee60), process radosgw, pid 14680
2013-06-07 21:06:11.453081 7fef2a085780 10 monclient(hunting): build_initial_monmap
2013-06-07 21:06:11.453494 7fef2a085780 1 librados: starting msgr at :/0
2013-06-07 21:06:11.453528 7fef2a085780 1 librados: starting objecter
2013-06-07 21:06:11.453627 7fef2a085780 1 -- :/0 messenger.start
2013-06-07 21:06:11.453683 7fef2a085780 1 librados: setting wanted keys
2013-06-07 21:06:11.453690 7fef2a085780 1 librados: calling monclient init
2013-06-07 21:06:11.453696 7fef2a085780 10 monclient(hunting): init
2013-06-07 21:06:11.453729 7fef2a085780 10 monclient(hunting): auth_supported 1 method none
2013-06-07 21:06:11.453858 7fef2a085780 10 monclient(hunting): _reopen_session
@jfriedly
jfriedly / gist:5486100
Created April 30, 2013 01:32
How to get the rows of a Pandas DataFrame where a column equals something

I loaded in ArcaCMD_LS_20061229.csv and I wanted to get all the trades involving AAON. The way to get them ended up being:

arca = pd.read_csv('ArcaCMD_LS_20061229.csv')
# This creates a Series of booleans
aaon_bool = arca['symbol'] == 'AAON'
# You can access rows given a series of booleans
aaon = arca[aaon_bool]
print len(aaon)
@jfriedly
jfriedly / regression-classification.rst
Created April 25, 2013 16:27
How to tell if you should use regression or classification

For example, let's say you want to predict movie rankings when your data is all integers in the 1 to 10 range. Classification might seem like a natural choice here, because the values are discrete, but it's actually better to use regression here because classification treats misclassifying a 5 as an 8 equal to misclassifying a 5 as a 6.

In general, use regression anytime there's a linear scale for the data. Classification is good for when there's many dimensions that don't correlate with each other well.

<source src="https://nebula-static.s3.amazonaws.com/video-4.mp4" type='video/mp4'/>
<source src="https://nebula-static.s3.amazonaws.com/video-3-small.mp4" type='video/mp4'/>
<source src="https://nebula-static.s3.amazonaws.com/video-4.webm" type='video/webm'/>
<source src="https://nebula-static.s3.amazonaws.com/video-4.ogg" type='video/ogg'/>
# as a one liner, just to say I told you so:
tail -f $HOME/.config/pianobar/out | sed 's/\x1b\[2K/\n/g' | gawk -v HOME="$HOME" ' BEGIN { i=0; while((getline line<"blacklist") > 0) songs[line]; } { for(song in songs) { if ( $0 == song ) { print "Skipping "song; print "n" > HOME"/.config/pianobar/ctl2"; } } } '
# With whitespace to make it easier to read:
tail -f $HOME/.config/pianobar/out |\
sed 's/\x1b\[2K/\n/g' |\
gawk -v HOME="$HOME" '
BEGIN{
i=0
@jfriedly
jfriedly / md-rst-test.rst
Last active December 15, 2015 08:19
Testing Github-flavored Markdown / reStructuredText

Rename this file between md-rst-test.rst and md-rst-test.md to see the respective versions.

EDIT: This doesn't work. See my comment below.

Example syntax-highlighted Python code using a reStructuredText 0.9 directive:

def foo():
@jfriedly
jfriedly / gist:5138827
Last active December 14, 2015 19:48
How to set the logging level to DEBUG in the Python interpreter without using basicConfig()
import logging
rootLogger = logging.getLogger()
rootLogger.setLevel(logging.DEBUG)
# Try logging.debug('foo') now!
#
# Note: if you have a module that uses a logger and you want it to log interactively, you'll need to
# import/reload it *after* running this code.
#
# This may also help: