Skip to content

Instantly share code, notes, and snippets.

View addisaden's full-sized avatar
🔍
Research Trip

addisaden addisaden

🔍
Research Trip
View GitHub Profile
@addisaden
addisaden / cv2_udp.py
Last active November 25, 2019 02:54
get an unbreakable (well everything is breakable) streaminput in opencv python. this could be a replacement for the rtsp streaming which are really fragile if used in VideoCapture
#!/bin/env python3
#-*- encoding: utf-8 -*-
import cv2
import numpy as np
# start this:
# ffmpeg -i /dev/video0 -f mpegts udp://localhost:1337
# ffmpeg -i rtsp://... -f mpegts udp://localhost:1337
var handler = {}
handler.decode = function() { return JSON.parse(decodeURIComponent(location.hash.replace(/^#/, ""))); }
handler.encode = function(obj) { location.hash = "#" + encodeURIComponent(JSON.stringify(obj)); return location.hash; }
@addisaden
addisaden / index.html
Last active September 3, 2015 10:36
How to implement a search-engine to your website
<html>
<head>
<link rel="search" type="application/opensearchdescription+xml" title="your search engine" href="/search.xml" />
</head>
</html>
// window.location.toString() => "http://localhost:7777/?search=bla+bli+blubb+%40+%22wababab+%26%2B13%22"
var b = {};
window.location.search.replace(/^\?/, "")
.split("&")
.map(function(e) {
var r = e.match(/([^=]+)=(.+)/);
return r ? [decodeURIComponent(r[1]), decodeURIComponent(r[2].replace(/\+/g, " "))] : [null, null];
})
.map(function(x) { b[x[0]] = x[1]; });
b // = { search: "bla bli blubb @ "wababab &+13"" }
var w20 = function(x, y) {
var wurf = Math.floor(Math.random() * 20) + 1;
var mustbe = Math.floor(20 - 20 * x / y) + 1;
return {wurf: wurf, mustbe: mustbe, result: wurf >= mustbe};
};
for(var y = 1; y <= 20; y++) {
for(var x = 1; x <= y; x++) {
var result;
do {
*.swp
*.swo
@addisaden
addisaden / CGW_PREDIGTEN.sh
Created May 10, 2015 09:19
Make a Playlist (m3u) of CGW preachings: http://meine-gemeinde.de/medien/predigten/
#!/bin/sh
# Hole Predigturls der Christusgemeinde Wuppertal (http://meine-gemeinde.de/medien/predigten/) und speichere diese in eine M3U-Playlist.
echo "#EXTM3U" > CGW_PREDIGTEN.m3u
curl "http://meine-gemeinde.de/medien/predigten/" | grep 'param name="movie"' | sed -r 's/^.*value="([^"]+)".*$/\1/g' | sed -r 's/%2F/\//g' | sed -r 's/.*song_url=([^&]+).+song_title=([^\n]+)/#EXTINF:0,\2\nhttp:\/\/meine-gemeinde.de\/\1/g' >> CGW_PREDIGTEN.m3u
@addisaden
addisaden / Rakefile
Created February 7, 2015 10:51
ruby dev environment with docker
task :dev do
filedir = File.dirname(File.expand_path(__FILE__))
system("docker run -it --rm -v #{ filedir }:/app -w='/app' ruby:2.2 /bin/bash")
end
@addisaden
addisaden / closure_example.c
Last active August 29, 2015 14:01
THIS FAILS .... Sorry ... How to make closures in C
#include <stdio.h>
void (*greeter(char greeting[]))(char[])
{
int intern_position = 1;
void result(char name[])
{
if(intern_position) return;
printf("%s, %s!\n", greeting, name);
#include <stdio.h>
const char gamer[3] = "XO";
int same_size(char a[], char b[])
{
int i;
for(i = 0;; i++) {
if(a[i] == '\0' || b[i] == '\0') {
return a[i] == b[i];