Skip to content

Instantly share code, notes, and snippets.

View naufraghi's full-sized avatar

Matteo Bertini naufraghi

View GitHub Profile
@naufraghi
naufraghi / is_regular_file.py
Created May 10, 2011 09:29
Detect [non] regular files in python
#!/usr/bin/env python
"""
$ echo "ciao" | python is_regular_file.py - <(cat comments.vim) comments.vim
'<stdin>' is not a regular file
'/dev/fd/63' is not a regular file
'comments.vim' is a regular file
"""
import os
import sys
@naufraghi
naufraghi / arima.c
Created April 9, 2011 10:20
R stats/arima.c
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 2002-2006 The R Development Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@naufraghi
naufraghi / as197.f
Created January 23, 2011 11:27
AS 197 A Fast Algorithm for the Exact Likelihood of Autoregressive-Moving Average Models (Melard 1984) [f2py]
SUBROUTINE FLIKAM(P,MP,Q,MQ,W,E,N,SUMSQ,FACT,VW,VL,
* MRP1,VK,MR,TOLER,IFAULT)
IMPLICIT DOUBLE PRECISION(A-H,O-Z)
C
Cf2py intent(in) P
Cf2py intent(hide) MP
Cf2py intent(in) Q
Cf2py intent(hide) MQ
Cf2py intent(in) W
Cf2py intent(out) E
@naufraghi
naufraghi / updatenx.py
Created November 24, 2010 12:10
Download latest nomachine nx debian packages
#!/usr/bin/python
import os
import sys
import urllib
import re
import glob
import platform
@naufraghi
naufraghi / sqlitedict.py
Created November 3, 2010 14:36
A persistent (sqlite3) dictionary
"""
A persistent (sqlite3) python dictionary
Based on:
http://erezsh.wordpress.com/2009/05/31/filedict-bug-fixes-and-updates/
Author: Erez Shinan
Date: 31-May-2009
Copyright 2010 Matteo Bertini <[email protected]>
Python Software Foundation License (PSFL)
@naufraghi
naufraghi / kmeans.py
Created June 29, 2010 15:47
kmeans algorithm in python + iris dataset (naive implementation)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2010 Matteo Bertini <[email protected]>
# Licensed as http://creativecommons.org/licenses/BSD/
#
# This is a naive implementation of the k-means unsupervised clustering
# algorithm (http://en.wikipedia.org/wiki/K-means_clustering).
from __future__ import division
import sys