Skip to content

Instantly share code, notes, and snippets.

View fradeve's full-sized avatar

Francesco de Virgilio fradeve

View GitHub Profile
@wilmoore
wilmoore / convert.sh
Created June 2, 2011 00:29
convert markdown to reStructured Text (Thanks Doctrine2) - https://github.com/doctrine/dbal-documentation/blob/master/convert.sh
#!/bin/bash
FILES=`find -iname *.txt -print`
for FILE in $FILES
do
# replace the + to # chars
sed -i -r 's/^([+]{4})\s/#### /' $FILE
sed -i -r 's/^([+]{3})\s/### /' $FILE
sed -i -r 's/^([+]{2})\s/## /' $FILE
sed -i -r 's/^([+]{1})\s/# /' $FILE
sed -i -r 's/(\[php\])/<?php/' $FILE
@drewda
drewda / gist:1299198
Created October 19, 2011 18:23
Jenks natural breaks classification
# code from http://danieljlewis.org/files/2010/06/Jenks.pdf
# described at http://danieljlewis.org/2010/06/07/jenks-natural-breaks-algorithm-in-python/
def getJenksBreaks( dataList, numClass ):
dataList.sort()
mat1 = []
for i in range(0,len(dataList)+1):
temp = []
for j in range(0,numClass+1):
temp.append(0)
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@esle
esle / dot.py
Created February 20, 2012 06:08
dot directive for reStructuredText, with this you can write ..dot:: things
"""
dot directive (require graphviz)
"""
from docutils import nodes
from docutils.parsers.rst import directives, Directive
import subprocess as sp
nthUnnamed = 0
@vjt
vjt / monitor.sh
Created February 23, 2012 17:19
Web server tmux monitoring session
#!/bin/sh
#
# Starts a multiplexed terminal session with tmux running monitoring software.
# Requires dstat, htop and grc. The apache configuration for grc can be found
# here: https://gist.github.com/1885569
#
# My .tmux.conf is here instead: https://gist.github.com/1886016#file_3_tmux.conf
#
# tmux 1.7 or later recommended.
#
@pblittle
pblittle / config
Created March 22, 2012 17:45
Vagrant ssh config to ssh/scp from host
Host vagrant
HostName localhost
User vagrant
Port 2210
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
IdentityFile /Users/pblittle/.rvm/gems/ruby-1.9.2-p290@wilbur/gems/vagrant-0.9.7/keys/vagrant
@nicolashery
nicolashery / solarized-dark.css
Last active March 25, 2022 08:38 — forked from scotu/solarized.css
Solarized theme stylesheets for Jekyll and Pygments
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@berkes
berkes / hamster2timetrap.rb
Created September 8, 2013 12:02
Quick-n-dirty import of hamster time tracking (https://projecthamster.wordpress.com) into timetrap (https://github.com/samg/timetrap).
require "sqlite3"
hamster = SQLite3::Database.new ".local/share/hamster-applet/hamster.db"
timetrap = SQLite3::Database.new ".timetrap.db"
unparsed = hamster.execute("select * from facts inner join activities on activities.id = facts.activity_id inner join categories on categories.id = activities.category_id")
entries = unparsed.map do |e|
timetrap.execute("insert into entries (note, start, end, sheet) values (?, ?, ?, ?)",
"#{e[6]} #{e[4]}",
@urschrei
urschrei / jenks_zero.py
Created September 22, 2013 17:45
Calculate Jenks natural breaks on a dataset containing zero values, using Pandas and Pysal
import pandas as pd
import numpy as np
from pysal.esda.mapclassify import Natural_Breaks as nb
df = pd.DataFrame({'density': np.random.randint(0, 10, 500)})
# replace zero values with NaN
df.replace(to_replace={'density': {0: np.nan}}, inplace=True)
breaks = nb(df[df['density'].notnull()].density.values, k=5)
# this index will allow us to perform the join correctly
@bitjockey42
bitjockey42 / mopidy.md
Created April 20, 2014 16:39
An installation and setup guide for mopidy on Arch Linux.

Mopidy on Arch Linux

mopidy

Installation

Install from the AUR.