Skip to content

Instantly share code, notes, and snippets.

View hannseman's full-sized avatar
⌨️
12:50, press return

Hannes Ljungberg hannseman

⌨️
12:50, press return
View GitHub Profile
func transformBuffer(buffer: AVAudioPCMBuffer) -> [Float] {
// Generate a split complex vector from the buffer data
var realp = [Float](count: Int(self.fftLength), repeatedValue: 0)
var imagp = [Float](count: Int(self.fftLength), repeatedValue: 0)
var dspSplitComplex = DSPSplitComplex(realp: &realp, imagp: &imagp)
var outFFTData = [Float](count: Int(self.fftLength), repeatedValue: 0)
// Apply blackman window
let windowSize = self.inMaxFramesPerSlice
!function ($) {
'use strict';
$.fn.task_poller = function (options) {
var interval_id;
var number_of_errors = 0;
if (typeof(options.on_failure) !== 'function') {
options.on_failure = function () {
};
def join_csv(path, destination):
import os
file_paths = os.listdir(path)
file_paths = [os.path.join(path, f) for f in file_paths]
header = None
with open(destination, 'wb') as join_file:
for path in file_paths:
with open(path, 'rb') as fp:
tmp_header = fp.readline()
if not header:
#!/usr/bin/env bash
function machine() {
if [ "$1" = "" ]; then
return 1
else
local machine_name="$1"
if [ $machine_name = "stop" ]; then
stop_machine
else
@hannseman
hannseman / keybase.md
Created October 6, 2015 20:17
keybase.md

Keybase proof

I hereby claim:

  • I am hannseman on github.
  • I am hannseman (https://keybase.io/hannseman) on keybase.
  • I have a public key whose fingerprint is C637 EB31 B56F F336 62CE 84D2 89F9 502D AC4C A6C1

To claim this, I am signing this object:

@hannseman
hannseman / evills
Created April 1, 2014 20:22 — forked from Eugeny/evills
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'http://github.com/cburgmer/upsidedown'
@hannseman
hannseman / uwsgi.py
Created January 9, 2014 16:44
Django cache backend using uwsgi caching framework
"""
uWSGI cache backend
http://projects.unbit.it/uwsgi/wiki/CachingFramework
"""
from __future__ import absolute_import
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
from django.utils.encoding import force_str
try:
import cPickle as pickle
@hannseman
hannseman / jsonp.txt
Created July 11, 2013 13:44
jsonp nginx support
location / {
# JSONP-support
if ( $arg_callback ) {
echo_before_body '$arg_callback(';
echo_after_body ');';
}
}
@hannseman
hannseman / swedish_stopwords.txt
Created May 19, 2013 19:11
Swedish stopwords
alla
allt
att
av
blev
bli
blir
blivit
de
dem
def batched_queryset(self, batch_size=1000):
"""
Yields queryset in batches specified by batch_size argument
"""
last_pk = self.order_by('-pk')[0].pk
queryset = self.order_by('pk')
start_index = 0
end_index = batch_size
while end_index < last_pk+batch_size:
yield queryset.all()[start_index:end_index]