Skip to content

Instantly share code, notes, and snippets.

View davideanastasia's full-sized avatar

Davide Anastasia davideanastasia

View GitHub Profile
@tonysimpson
tonysimpson / hexbinmapplot.py
Created April 27, 2013 13:07
Plotting hexbin on a map projection using Basemap and Mapplotlib
from matplotlib import pylab # .exe install is on sourceforge
import numpy# easy_install numpy
from mpl_toolkits.basemap import Basemap # easy_install basemap
# functions to create some random data points and convert them to meters via the map projection
def create_points_in_lon_lat(N=10000):
return zip(numpy.random.standard_normal(N)*360, numpy.random.standard_normal(N) * 45)
def convert_lon_lat_points_to_meters_using_transform(points, tran):
# maybe there is a better way to get long/lat into meters but this works ok
@joemiller
joemiller / raid_ephemeral.sh
Last active October 23, 2023 21:53
detect all ephemeral disks on EC2 then stripe together in a raid-0 vol mounted at /mnt
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
@freeman-lab
freeman-lab / bisecting.scala
Last active December 29, 2015 07:45
Bisecting k-means for hierarchical clustering in Spark
/**
* bisecting <master> <input> <nNodes> <subIterations>
*
* divisive hierarchical clustering using bisecting k-means
* assumes input is a text file, each row is a data point
* given as numbers separated by spaces
*
*/
import org.apache.spark.SparkContext
@yxtay
yxtay / tensorflow_word2vec_cbow_basic.py
Last active December 21, 2023 03:25
Basic implementation of CBOW word2vec with TensorFlow. Minimal modification to the skipgram word2vec implementation in the TensorFlow tutorials.
# References
# - https://www.tensorflow.org/versions/r0.10/tutorials/word2vec/index.html
# - https://github.com/tensorflow/tensorflow/blob/r0.10/tensorflow/examples/tutorials/word2vec/word2vec_basic.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import math