Skip to content

Instantly share code, notes, and snippets.

@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 / sc_examples.scd
Created September 10, 2012 22:01
SuperCollider examples
// SuperCollider Examples
//boot server
s.boot;
// SC as system for sound synthesis and sound processing
// patching synth moduls by writing synth defs:
@ptrv
ptrv / build-zsh.sh
Created July 7, 2011 23:01 — forked from nicoulaj/build-zsh.sh
Build Zsh from sources on Ubuntu
#!/bin/sh​
# Build Zsh from sources on Ubuntu.
# From http://zsh.sourceforge.net/Arc/git.html and sources INSTALL file.
# Some packages may be missing
sudo apt-get install -y git-core gcc make autoconf yodl libncursesw5-dev texinfo
git clone git://zsh.git.sf.net/gitroot/zsh/zsh
cd zsh
@ptrv
ptrv / spatialite_example.go
Last active September 8, 2022 02:48
SpatiaLite example in Go
package main
import (
"database/sql"
"github.com/mattn/go-sqlite3"
"log"
"os"
)
func runQuery(db *sql.DB, query 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 / GpxTrackNameChanger.py
Created February 5, 2011 15:18
Change track names in GPX files (python)
#!/usr/bin/python
# Script for assigning the date of a track in a GPX file as track name.
#
# Usage e.g $ python ChangeGpxTrackName.py source.gpx target.gpx"
#
# Peter Vasil
# Date: 2011-02-05
from optparse import OptionParser
@ptrv
ptrv / vim gpg interface
Created April 14, 2012 21:28
vim gpg interface
" Transparent editing of gpg encrypted files.
" By Wouter Hanegraaff <wouter@blub.net>
augroup encrypted
au!
" First make sure nothing is written to ~/.viminfo while editing
" an encrypted file.
autocmd BufReadPre,FileReadPre *.gpg set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.gpg set noswapfile
" Switch to binary mode to read the encrypted file
(defhydra ptrv/smartparens (:hint nil)
"
Sexps (quit with _q_)
^Nav^ ^Barf/Slurp^ ^Depth^
^---^------------^----------^-----------------^-----^-----------------
_f_: forward _→_: slurp forward _R_: splice
_b_: backward _←_: barf forward _r_: raise
_u_: backward ↑ _C-<right>_: slurp backward _↑_: raise backward
_d_: forward ↓ _C-<left>_: barf backward _↓_: raise forward
_p_: backward ↓
@ptrv
ptrv / spring.py
Created November 17, 2012 01:35
Simple force directed graph drawing algorithm
#!/usr/bin/env python
# Force-Directed Graph Drawing
import Tkinter
import random
import math
# d = [
# [.0, .3, .3, .0],
@ptrv
ptrv / .ctags.txt
Created January 20, 2013 01:41
ctags language support for latex and bibtex
--langdef=latex
--langmap=latex:.tex .latex
--regex-latex=/^\\part[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/PART \2/s,part/
--regex-latex=/^\\part[[:space:]]*\*[[:space:]]*\{([^}]+)\}/PART \1/s,part/
--regex-latex=/^\\chapter[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/CHAP \2/s,chapter/
--regex-latex=/^\\chapter[[:space:]]*\*[[:space:]]*\{([^}]+)\}/CHAP \1/s,chapter/
--regex-latex=/^\\section[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\2/s,section/
--regex-latex=/^\\section[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\1/s,section/
--regex-latex=/^\\subsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/-\2/s,subsection/
--regex-latex=/^\\subsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/-\1/s,subsection/