Skip to content

Instantly share code, notes, and snippets.

View dh1tw's full-sized avatar

Tobias Wellnitz dh1tw

View GitHub Profile
@geografa
geografa / haversine_bearing.py
Created November 15, 2011 07:38
Haversine formula example in Python for calculating bearing
#!/usr/bin/env python
# Haversine formula example in Python for Calculating Bearing
# Inspired from http://www.movable-type.co.uk/scripts/latlong.html
import math
def bearing(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
@lowstz
lowstz / auto-ovpn.sh
Created February 8, 2012 15:22 — forked from xream/MacVPN.sh
Linux openvpn auto reconnect script
#!/bin/bash
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
### Thanks Xream's Work XD
# if you don't have several vpn servers to select, you can comment following line
# and use your openvpn config file name to replace "${host}.ovpn" in while loop.
read -p "Select the host: " host
@jobliz
jobliz / RedisPythonPubSub1.py
Created May 4, 2012 17:58
A short script exploring Redis pubsub functions in Python
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@yoggy
yoggy / SerialPort.cpp
Created August 11, 2012 10:58
SerialPort class sample using boost::asio::serial_port
#include "StdAfx.h"
#include <Setupapi.h>
#pragma comment(lib, "Setupapi.lib")
#include "SerialPort.h"
SerialPort::SerialPort(void) : end_of_line_char_('\n')
{
}
@livibetter
livibetter / README.rst
Last active January 22, 2021 08:39
Frequency spectrum of sound using PyAudio, NumPy, and Matplotlib
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active April 18, 2024 16:07
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@fatih
fatih / ring.go
Created December 24, 2013 00:47
container/ring example golang
package main
import (
"container/ring"
"fmt"
"time"
)
func main() {
coffee := []string{"kenya", "guatemala", "ethiopia"}
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
@markandrus
markandrus / server.js
Created July 9, 2014 01:01
WebRTC Test Client
// This is the signaling server for relaying messages between Node.js and
// Chrome. Run it with
//
// $ node server.js
//
function SignalingServer() {
var clients = {};
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({
@mattes
mattes / check.go
Last active April 4, 2024 22:40
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}