Skip to content

Instantly share code, notes, and snippets.

View nicolamontecchio's full-sized avatar

Nicola Montecchio nicolamontecchio

View GitHub Profile
@nicolamontecchio
nicolamontecchio / gist:3915046
Created October 18, 2012 22:04
maven "uberjar"
add this stuff:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.nicolamontecchio.gnappo.Gnappo</mainClass>
@nicolamontecchio
nicolamontecchio / gist:3984652
Last active October 12, 2015 06:28
cmake template, for c++11
cmake_minimum_required(VERSION 2.6)
project(ml)
add_library(boost_po STATIC IMPORTED)
set_property(TARGET boost_po PROPERTY
IMPORTED_LOCATION /usr/local/lib/libboost_program_options.a)
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
@nicolamontecchio
nicolamontecchio / gist:5758728
Created June 11, 2013 17:10
sample discrete distrib in python
def sample_discrete(probabilities):
bins = np.add.accumulate(probabilities)
return np.digitize([random.random()], bins)
@nicolamontecchio
nicolamontecchio / gist:7141034
Created October 24, 2013 17:01
generally useful stuff

avoiding cmd line buffering between pipes or such

brew install homebrew/dupes/expect

unbuffer ./blablabla | ... | ...

@nicolamontecchio
nicolamontecchio / gist:7416413
Last active December 28, 2015 00:49
general wisdom
Force git to overwrite local files on pull (fixed homebrew w/ this)
git fetch --all
git reset --hard origin/master
find ip address from cmdline
wget -qO- http://ipecho.net/plain ; echo
package com.nicolamontecchio.chroma;
import java.io.*;
import javax.sound.sampled.*;
/**
* Read an audio file. Provided that the appropriate packages are in the classpath, mp3 and ogg should be readable too. The safest route is to read from a MONO, WAV file.
*/
public class AudioReader {
@nicolamontecchio
nicolamontecchio / foo.c
Created January 16, 2014 04:00
template for python extension in C
#include <Python.h>
static PyObject* say_hello(PyObject* self, PyObject* args)
{
const char* name;
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
printf("Hello %s!\n", name);
@nicolamontecchio
nicolamontecchio / .emacs
Created January 17, 2014 18:15
emacs config as of 2014-01-17
;; ;; config using mac-port of emacs,
;; ;; see https://github.com/railwaycat/emacs-mac-port
;; ;; mac switch meta key
(setq mac-option-modifier 'meta)
(setq mac-command-modifier 'hyper)
(setq package-archives '(;;("gnu" . "http://elpa.gnu.org/packages/")
;;("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
@nicolamontecchio
nicolamontecchio / -
Created February 11, 2014 15:34
fast cat of a lot of files
find . -name "*.dat" -exec cat {} \; > filename
@nicolamontecchio
nicolamontecchio / -
Created July 1, 2014 14:25
clojure ZIP function
;; zip sequences:
(map vector v1 v2 v3 ...)