Skip to content

Instantly share code, notes, and snippets.

@ptrv
ptrv / bjorklund.lua
Created December 2, 2015 01:03
bjorklund algorithm
function bjorklund3(steps, pulses)
local pattern = {}
local counts = {}
local remainders = {}
local divisor = steps - pulses
table.insert(remainders, pulses)
local level = 1
local run = true
while run do
table.insert(counts, divisor / remainders[level])
@ptrv
ptrv / cut_audio.py
Created November 22, 2015 21:47
split audio file into multiple pieces
import sys
import subprocess
input_file = sys.argv[1]
seconds = sys.argv[2]
num_pieces = sys.argv[3]
for i in range(num_pieces):
num = i * seconds
output = "output/{0}.wav".format(i)
@ptrv
ptrv / fft.py
Created November 22, 2015 21:44
compute frequencies
import matplotlib.pyplot as plt
import numpy as np
import scipy
import scipy.fftpack
import scipy.io.wavfile
import heapq
from datetime import datetime
# from itertools import izip
Fs, y = scipy.io.wavfile.read("sine.wav")
@ptrv
ptrv / .ycm_extra_conf.py
Created October 28, 2015 22:29
Default ycmd_extra_conf.py file
import os
import re
import subprocess
import ycm_core
def LoadSystemIncludes():
regex = re.compile(ur'(?:\#include \<...\> search starts here\:)(?P<list>.*?)(?:End of search list)', re.DOTALL);
process = subprocess.Popen(['clang', '-v', '-E', '-x', 'c++', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE);
process_out, process_err = process.communicate('');
output = process_out + process_err;
#include <string>
/* this is a test: åøæ */
namespace {
int føø(const std::string& x) {
}
@ptrv
ptrv / flycheck-luacheck.el
Last active December 29, 2019 06:25
Flycheck syntax checker for Lua using luacheck
;;; flycheck-luacheck.el --- Flycheck syntax checker using luacheck -*- lexical-binding: t; -*-
;; Copyright (C) 2015 Peter Vasil
;; Author: Peter Vasil <mail@petervasil.net>
;; Keywords:
;; 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 3 of the License, or
@ptrv
ptrv / lookup_ip_address_by_user_defined_ethernet_name.mm
Created February 26, 2015 16:24
Lookup IP Address by User Defined Ethernet Name on Mac OS X
//
// includes
//
#import <SystemConfiguration/SystemConfiguration.h>
#import <CoreFoundation/CoreFoundation.h>
#import <arpa/inet.h>
#import <string>
//
// desc: convert IPv4 address from binary format to numbers-and-dots notation in a string
@ptrv
ptrv / cyberpunk-ptrv.el
Created February 18, 2015 21:00
modified emacs-live default theme
;; Cyberpunk Colour Theme
;;
;; "and he'd still see the matrix in his sleep, bright lattices of logic
;; unfolding across that colorless void..."
;; William Gibson, Neuromancer.
;;
(require 'color-theme)
;;;###autoload
@ptrv
ptrv / emacs.rb
Created February 10, 2015 23:44
require "formula"
class Emacs < Formula
homepage "https://www.gnu.org/software/emacs/"
stable do
url "http://ftpmirror.gnu.org/emacs/emacs-24.4.tar.xz"
mirror "https://ftp.gnu.org/pub/gnu/emacs/emacs-24.4.tar.xz"
sha256 "47e391170db4ca0a3c724530c7050655f6d573a711956b4cd84693c194a9d4fd"
@ptrv
ptrv / lldb-gud-emacs-25.patch
Last active October 17, 2017 14:55
lldb-gud patch from llvm.org for emacs 25
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 42c5b20..0f6f412 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -35,7 +35,7 @@
;; kluge with the gud-xdb-directories hack producing gud-dbx-directories.
;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java
;; debugger.) Jan Nieuwenhuizen added support for the Guile REPL (Guile
-;; debugger).
+;; debugger). llvm.org added support for lldb.