Skip to content

Instantly share code, notes, and snippets.

@marvin
marvin / client.py
Created December 17, 2012 13:50
simple python client/server socket binary stream
import socket
HOST = 'localhost'
PORT = 9876
ADDR = (HOST,PORT)
BUFSIZE = 4096
videofile = "videos/royalty-free_footage_wien_18_640x360.mp4"
bytes = open(videofile).read()
@marvin
marvin / tkinter-hyperlinks.py
Created November 22, 2012 09:48
tkinter with hyperlinks
@marvin
marvin / pretty.go
Created November 9, 2022 15:20
golang json struct helper functions
// Prints objects into json pretty output
func PrettyStruct(data interface{}) (string, error) {
val, err := json.MarshalIndent(data, "", " ")
if err != nil {
return "", err
}
return string(val), nil
}
// pretty print coded byte in json format
@marvin
marvin / ESXi_backup.pl
Last active November 3, 2022 12:38
esxi backup script - includes email notifications etc
#
#
#
use strict;
use warnings;
use MIME::Lite;
################-- VARIABLES --############################
@marvin
marvin / gist:1017480
Created June 9, 2011 19:16
syslog calculate facility and severity from PRI(priority)
example:
PRI = 191
To get the Facility
Divide the PRI number by 8.
191/8 = 23.875
The whole number part is the facility.
To get the Severity
@marvin
marvin / stopstart_movingbox.html
Created February 26, 2012 20:56
moving box in html,css and js will stop/start if S key is pressed or left button is clicked
<html>
<head>
<title>moving box - stops/starts on left click</title>
<style type='text/css'>
#game_region {
width: 600px;
height: 400px;
background-color: black;
position:relative;
@marvin
marvin / example1.py
Created December 17, 2012 23:19
python gtk examples
from gi.repository import Gtk
class MyDemoApp():
def __init__(self):
window = Gtk.Window()
window.set_title("My demo window")
window.set_default_size(500, 300)
window.set_position(Gtk.WindowPosition.CENTER)
@marvin
marvin / mydns-create-table.sql
Created June 2, 2012 18:45
MyDNS postgresql create-table
--
-- Table layouts for mydns 1.2.8.11 (Jun 2012)
-- Copyright (C) 2002-2005 Don Moore 2007-2008 Howard Wilkinson
--
-- You might create these tables with a command like:
--
-- $ mydns --create-tables | psql -h HOST -U USER DATABASE
--
--
@marvin
marvin / cidr2iplist.py
Created March 9, 2022 11:02
a script to convert a cidr/ip network list to a list of ip addresses
#!/usr/bin/python3
# writte by David "marvin" Nölte - 2022
# this script reads a file with a list of ip subnets/cirds and outputs it to a ip list
# input file can be a list of subnets/one per line
# check "./cidr2list.py -h"
import os
import ipaddress
import argparse
@marvin
marvin / xna-movePlayerToMousePosition.cs
Created July 17, 2012 06:47
xna move play to mouse direction
// The spritebatch has a draw method that takes in a rotation angle, you can see the overloads for draw here.
//First, you would want to get the mouse's location and store it as a vector;
MouseState curMouse = Mouse.GetState();
Vector2 mouseLoc = new Vector2(curMouse.X, curMouse.Y);
// Next, subtract the mouse's position from the sprite's position to get the direction (as a vector) that the sprite should face and convert it to a angle measured in radians;
Vector2 direction = (sprite's position) - mouseLoc;
float angle = (float)(Math.Atan2(direction.Y, direction.X));