Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

def histogram(filename):
with open(filename) as fd:
return Counter(w.strip().lower() for w in fd.read().split()
if not (w in nltk.corpus.stopwords.words('english') )).most_common()
print '\n'.join("{}:{}".format(x,y) for x,y in histogram('/Users/fabrizio/Desktop/input.txt'))
@Mistobaan
Mistobaan / gist:5374118
Last active December 16, 2015 03:59 — forked from tkdave/gist:4150916
# Installing OpenCV python libs on mac to work with virtualenv
# OpenCV 2.4.3
# Python 2.7.3 installed with brew
# download CUDA https://developer.nvidia.com/cuda-downloads
# OpenNI SDK http://www.openni.org/openni-sdk/?download=http://www.openni.org/wp-content/uploads/2013/01/OpenNI-MacOS-x64-2.1.0.tar.zip#.UWhRlyt4YRk
# assuming you have virtualenv, pip, and python installed via brew
# assuming $WORKON_HOME is set to something like ~/.virtualenvs
# using homebrew - make sure we're current
@Mistobaan
Mistobaan / reflect_func_example
Created May 9, 2013 18:22
Example of a Reflected function in Go 1.1
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"reflect"
"runtime"
"strings"
@Mistobaan
Mistobaan / README.md
Created May 11, 2013 19:27
Run MavProxy on SITL mode on Macosx

Inside the ubuntu virtual machine:

ardupilot/Tools/autotest/sim_arduplane.sh

on your mac:

Run Simulator:

$ export PATH=$WORKSPACE/jsbsim/src/:$PATH $ ardupilot/Tools/autotest/jsbsim/runsim.py --home=-35.362938,149.165085,584,270

Avi Flax wrote a very interesting article about Profiling Node Programs on Mac OS X. However, if you manage your Node.js installation with homebrew, you can use the following scripts to install the V8 debugger separately.

Just download this Gist, make install.sh executable with chmod u+x install.sh and run the script.

// Provided by package runtime.
func now() (sec int64, nsec int32)
// Now returns the current local time.
func Now() Time {
sec, nsec := now()
return Time{sec + unixToInternal, nsec, Local}
}
@Mistobaan
Mistobaan / Dockerfile
Created November 11, 2013 18:27
docker file for ubuntu
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - ; \
apt-get update; \
apt-get -y install postgresql-9.3-postgis
apt-get -y install postgresql-contrib
# Setup PostgreSQL
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "host all docker 0.0.0.0/0 trust" >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "listen_addresses = '*'" >> /etc/postgresql/9.3/main/postgresql.conf
@Mistobaan
Mistobaan / snippet
Created November 18, 2013 03:11
Capturing an image with google Glasses
public void onClick(View v) {
Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(captureIntent, REQUEST_IMAGE_CAPTURE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK
&& null != data) {
@Mistobaan
Mistobaan / logapi.go
Created February 10, 2014 03:22
Logging Handler
package programs
import (
"encoding/base64"
"html/template"
"net/http"
"time"
"appengine"
"appengine/log"
[info] Loading project definition from /home/fmilo/example-scala-build/project
[info] Set current project to amx-livescore (in build file:/home/fmilo/example-scala-build/)
[info] Updating {file:/home/fmilo/example-scala-build/}default-eb146d...
[info] Resolving org.eclipse.jetty#jetty-server;7.6.8.v20121106 ...
[error] Server access Error: Connection timed out url=https://repository.cloudera.com/artifactory/cloudera-repos/org/eclipse/jetty/jetty-server/7.6.8.v20121106/jetty-server-7.6.8.v20121106.pom
[info] Resolving org.eclipse.jetty#jetty-project;7.6.8.v20121106 ...
[error] Server access Error: Connection timed out url=https://repository.cloudera.com/artifactory/cloudera-repos/org/eclipse/jetty/jetty-project/7.6.8.v20121106/jetty-project-7.6.8.v20121106.pom
[info] Resolving org.eclipse.jetty#jetty-parent;20 ...
[error] Server access Error: Connection timed out url=https://repository.cloudera.com/artifactory/cloudera-repos/org/eclipse/jetty/jetty-parent/20/jetty-parent-20.pom
[error] Server access Error: Con