Skip to content

Instantly share code, notes, and snippets.

View glciampaglia's full-sized avatar

Giovanni Luca Ciampaglia glciampaglia

View GitHub Profile
@glciampaglia
glciampaglia / carray_test.py
Last active December 18, 2015 20:49
Code for writing a sparse adjacency matrix in COO format to PyTable's CArray representation.
# Adapted from
# http://pytables.github.io/usersguide/libref/homogenous_storage.html#the-carray-class
import os
import numpy
import tables
from itertools import groupby
from operator import itemgetter
from time import time
@glciampaglia
glciampaglia / weave_add_edges.py
Last active December 19, 2015 00:29
Using Weave to speed up batch edge insertion with graph-tool
from time import time
import numpy as np
from graph_tool import Graph
from graph_tool.run_action import inline
def add_edges(graph, edges):
'''
Batch edges insertion. Pure Python implementation.
@glciampaglia
glciampaglia / gist:5877320
Created June 27, 2013 15:16
Shell enviroment for Python development on the CNetS servers.
# Use the Python 2.7 installation in /l/
PYTHONROOT=/l/python2.7
export PATH=$PYTHONROOT/bin:$PATH
export LD_LIBRARY_PATH=$PYTHONROOT/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$HOME/local/lib/python:$PYTHONPATH
# My own local libraries and python modules are in ~/local
export PATH=$HOME/local/bin:$PATH
export MANPATH=$HOME/local/man:$MANPATH
@glciampaglia
glciampaglia / refdict.py
Last active December 20, 2015 12:49
A dictionary class that stores references to duplicate values. Values must be hashable types.
class RefDict(dict):
def __init__(self, *args, **kwargs):
'''
A dictionary that stores references to a set of values. It gives an
advantage in terms of memory when one needs to store several large
duplicate objects.
Note
----
Values must be hashable. Instead of lists, use tuples; instead of sets,
### General Chairs
[<img style="margin-bottom: 10px; margin-right: 10px" alt="Fil Menczer" src="img/org/Fil_Menczer.png"/>](http://bit.ly/filmenczer) [Fil Menczer, IU](http://bit.ly/filmenczer)<br/>
[<img style="margin-bottom: 10px; margin-right: 10px" alt="Jim Hendler" src="img/org/Jim_Hendler.jpg" />](http://www.cs.rpi.edu/~hendler/) [Jim Hendler, RPI](http://www.cs.rpi.edu/~hendler/)<br/>
[<img style="margin-bottom: 10px; margin-right: 10px" alt="William Dutton" src="img/org/william_dutton.jpg" />](http://people.oii.ox.ac.uk/dutton/) [William Dutton, Oxford](http://people.oii.ox.ac.uk/dutton/)<br/>
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,
@glciampaglia
glciampaglia / stream.py
Created November 12, 2018 19:27
Client for the filter endpoint of the Twitter Streaming API
#!/usr/bin/env python
# vim: set sw=4 sts=4 expandtab:
# author: Giovanni Luca Ciampaglia <gciampag@indiana.edu>
# TODO: set request timeout to 90 seconds to manage stalls and implement
# backoff strategies as documented here:
# https://dev.twitter.com/streaming/overview/connecting (see Stalls and
# Reconnecting)
#
# and also see:
@glciampaglia
glciampaglia / bmctest.py
Created May 7, 2022 22:11
Bimodality coefficient (BMC)
# IPython log file
import sys
import numpy
numpy.set_printoptions(precision=2, suppress=True)
import scipy
import scipy.stats
print("Python version = {sys.version}".format(sys=sys))
print("NumPy version = {numpy.version.version}".format(numpy=numpy))
@glciampaglia
glciampaglia / test_selenium.py
Created May 7, 2022 22:16
Selenium test (Chrome webdriver)
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.expected_conditions import \
presence_of_element_located
# This example requires Selenium WebDriver 3.13 or newer