Skip to content

Instantly share code, notes, and snippets.

@vanne02135
vanne02135 / vector.py
Created February 6, 2010 14:34
Simple vector class, only element-wise multiplication and addition implemented
import array
class vector():
def __init__(self, d):
if type(d) is int:
self.data = array.array('f', [0]*d)
elif type(d) is list:
self.data = array.array('f', d)
else:
@vanne02135
vanne02135 / rt60.m
Created February 11, 2010 21:18
Matlab function to determine RT60 reverberation time from burst signals. Works at least with 2 of my recorded samples of clapping hands.
function r = rt60(s, Fs)
% rt60 (s, Fs) : determine reverberation time from signal s with sampling
% frequency Fs (44100 Hz for most wav's).
t = (0:(length(s)-1))'/Fs;
dt = 1/Fs;
s2 = abs(s);
s2 = s.^2;
s2db = 10*log10(s2/max(s2));
@vanne02135
vanne02135 / YetAnotherPhotoView.py
Created February 16, 2010 22:11
Playing around with Pyglet and it's OpenGL interface to show some photos. Requires Pyglet and PIL. Displays some public photos from my flickr photostream.
__author__="vanne"
__date__ ="$16.2.2010 22:02:26$"
from pyglet.gl import *
import pyglet
from pyglet.window import *
from pyglet import image
import os
@vanne02135
vanne02135 / index.html
Created February 25, 2010 20:57
Just testing a little js math expression parser http://github.com/silentmatt/js-expression-eval
<html>
<head>
</head>
<body>
<!-- we will add our HTML content here -->
<script type="text/javascript" src="parser.js"></script>
<script type="text/javascript">
function myParser(){
/* create a Date object using the system clock */
@vanne02135
vanne02135 / ProxyTest.py
Created March 3, 2010 21:25
Simple speed test to check if local virtual box squid installation helps boosting the download speed from Flickr
import time
import urllib
import sys
__author__="vanne"
__date__ ="$3.3.2010 22:18:10$"
class ProxyTest:
# 192.168.11.5 is a virtual box running ubuntu and squid
proxies = {'http': 'http://192.168.11.5:3128'}
testurl = "http://farm3.static.flickr.com/2739/4358723026_84d9045990_o.jpg";
@vanne02135
vanne02135 / my_port_scanner.py
Created May 21, 2010 12:54
Test for open ports
import socket
import sys
host = sys.argv[1]
maxport = int(sys.argv[2])
for k in range(1, maxport):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.5)
@vanne02135
vanne02135 / parse_access_log.py
Created May 31, 2010 08:13
Parse apache access logs to show host names and connection times
#!/usr/bin/python
import sys
import socket
line = sys.stdin.readline()
lasthost = ""
while len(line) != 0:
mylist = line.split()
if mylist[0] == lasthost:
@vanne02135
vanne02135 / trianglesoup.cpp
Created December 22, 2010 21:06
Will contain visibility functionality for triangle soup some day
/*
* File: main.cpp
* Author: vanne
*
* Created on December 22, 2010, 10:00 PM
*/
#include <cstdlib>
#include <iostream>
#include <vector>
@vanne02135
vanne02135 / ParaView_ProgSource_CreatePoints.py
Created March 29, 2011 18:40
Create 3D points with associated data in Paraview Programmable source
# run in paraview programmable source
import math
pdo = self.GetOutput()
myPts = vtk.vtkPoints()
myData = vtk.vtkDoubleArray()
myData.SetName("MyData")
myData.SetNumberOfComponents(2)
@vanne02135
vanne02135 / calFetch.js
Created May 2, 2011 21:52
Get calendar entries to spreadsheet on Google Apps (see Tools -> Script Editor on Google Spreadsheets)
function onOpen() {
// create menu entry for starting calFetch script
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [{name: "Get calendar entries", functionName: "calFetch"}];
ss.addMenu("Calendar", menuEntries);
}
function calFetch() {
// get calendar entries and show them and total times