Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python2.5
# vim:set fileencoding=utf-8
import os
import sys
import tagpy
from lucene import \
Document, IndexSearcher, FSDirectory, MultiFieldQueryParser, QueryParser, StandardAnalyzer, IndexWriter, \
StringReader, IndexReader, MoreLikeThis, Term, TermQuery, BooleanQuery,BooleanClause , Field, initVM, CLASSPATH
def indexFilesFromPath(dir, idxPath):
def indexFilesFromPath(dir, idxPath):
initVM(CLASSPATH)
writer = IndexWriter(idxPath, StandardAnalyzer(), True)
count = 1
for root, dirs, files in os.walk(dir):
for file in files:
#print "- "+str(root)+" "+file
sfx = file[-3:]
if sfx.lower() not in [ "mp3","mp4", "ogg", "flac" ]:
continue
def search( searchRequest, idxPath):
initVM(CLASSPATH)
fsDir = FSDirectory.getDirectory(idxPath, False)
searcher = IndexSearcher(fsDir)
language = StandardAnalyzer()
queryp = QueryParser('all', language)
query = queryp.parse(searchRequest) # "title", language)
hits = searcher.search(query)
print "# Found %d hits for %s"%(len(hits), searchRequest)
#!/bin/bash
ffmpeg -threads 2 -i $1 -vcodec libx264 -g 30 -deinterlace -b 900k -s 640x360 -padtop 60 -padbottom 60 -padcolor 000000 -aspect 4:3 -acodec mp3 -ab 64k $2
import sys
from lxml import etree
CARD_MULT=1
CARD_SINGLE=0
class xmlStor:
properties = {}
# multipart post. Original from http://code.activestate.com/recipes/146306/
# use StringIO or fd instead of buffer
import mimetools
import magic
def getMime(content):
ms = magic.open(magic.MAGIC_MIME)
ms.load()
magic_s = ms.buffer(content[:1024])
@dopuskh3
dopuskh3 / tornado_octet-stream.py
Created November 26, 2009 08:43
How to get the content of a POST with Content-type application/octet-stream with tornado
class EntryListHandler(tornado.web.RequestHandler):
def post(self, ressource_name):
# Get file content and mime type
fileContent = None
try:
fileContent = self.request.files['fname'][0]['body']
except Exception, e:
if self.request.headers.has_key('Content-Type') and self.request.headers['Content-Type'].startswith("application/octet-stream"):
fileContent = self.request.body
Index: ofSoundStream.cpp
===================================================================
--- ofSoundStream.cpp (révision 294)
+++ ofSoundStream.cpp (copie de travail)
@@ -7,31 +7,31 @@
int nInputChannels;
int nOutputChannels;
ofAudioEventArgs audioEventArgs;
-int receiveAudioBufferAndCallSimpleApp(char *buffer, int bufferSize, void *data);
+//int receiveAudioBufferAndCallSimpleApp(char *buffer, int bufferSize, void *data);
#!/bin/sh
# set -x
HEIGHT=1024
WIDTH=768
FPS=15
OUT=$1
VLC=vlc
# for os x use:
# VLC=/Applications/VLC.app/Contents/MacOS/VLC
import os, sys, httplib2, random
buf_min = 1024
buf_max = 2048
def postStress(uri):
f = open("/dev/urandom", "r")
h = httplib2.Http()