Skip to content

Instantly share code, notes, and snippets.

View hubertgrzeskowiak's full-sized avatar
🚀
Ad space for rent (JK)

Hubert Grzeskowiak hubertgrzeskowiak

🚀
Ad space for rent (JK)
View GitHub Profile
@hubertgrzeskowiak
hubertgrzeskowiak / git-cleanup-branches.sh
Last active March 14, 2019 02:53
Script for removing unused local branches
#!/usr/bin/env bash
# Cleaner for local branches that have no remotes any more.
# Not yet pushed local branches are untouched.
#
# For convencience, add to ~/.gitconfig as:
#
# [alias]
# cleanup-branches = !~/bin/git-cleanup-branches.sh
#
@hubertgrzeskowiak
hubertgrzeskowiak / NodeJS D3 with JSDOM
Last active November 12, 2023 17:37
Using d3.js (aka Data-Driven Documents) without browser with help of jsdom. This allows for server-side rendering or programmatic use in any other contexts than browser.
d3 = require("d3");
jsdom = require("jsdom");
document = jsdom.jsdom();
window = document.parentWindow;
var sampleSVG = d3.select(document.body)
.append("svg")
.attr("width", 100)
.attr("height", 100)
@hubertgrzeskowiak
hubertgrzeskowiak / Eclipse .classpath to CLASSPATH
Last active December 24, 2019 04:35
This small script converts a .classpath file as Eclipse IDE creates it into a colon-separated CLASSPATH line which you can use as command line parameter to Java or as environment variable.
#!/bin/env python
"""
This small script converts a .classpath file as Eclipse IDE creates it into a colon-separated
CLASSPATH line which you can use as command line parameter to Java or as environment variable.
"""
import sys
from bs4 import BeautifulSoup as bs
@hubertgrzeskowiak
hubertgrzeskowiak / Python Composition Decorator
Created December 22, 2012 02:33
With this method decorator you can make a method a method container or -composition. See the included example to see how it works.
class composition(object):
"""This is a composition decorator, which allows a function to be used as a container for functions.
On call, all the functions contained will be called.
Keep in mind, though, that the decorated function itself won't be included/called.
"""
class NoSuchElementError(Exception):
def __init__(self):
Exception.__init__(self, "You tried to remove an element from a composition that was not existent.")
class ElementNotCallableError(Exception):
def __init__(self):
@hubertgrzeskowiak
hubertgrzeskowiak / FH Koeln PSSO Notenberechnung
Last active October 12, 2015 09:38
Dieses kleine Python Script berechnet anhand der HTML Webseite vom PSSO den eigenen Schnitt und Anzahl der Credits. Es wird die Python Bibliothek BeautifulSoup 4 benötigt.
# encoding: utf-8
import sys
from bs4 import BeautifulSoup
if len(sys.argv) != 2:
print "Dieses Programm benötigt eine html Datei als Parameter!"
print "Speichere deine PSSO Seite, auf der die Noten zu sehen sind"
print "und gib den Namen auf der Kommandozeile als Parameter an."
print "Zum Beispiel: python noten.py rds.html"
sys.exit(1)
@hubertgrzeskowiak
hubertgrzeskowiak / Panda3D hosted by wxPython as Subprocess.py
Last active October 28, 2020 11:24
This is an example on how to create a Panda3d instance in a subprocess, which window is hosted in a wxPython panel. This approach has the advantage of scope separation (both libraries define globals) and framerate independence. The disadvantage is the more complex communication between the processes.
import sys
import os
from multiprocessing import Process, Pipe
import wx
from direct.task import Task
from pandac.PandaModules import WindowProperties
from pandac.PandaModules import loadPrcFileData
from direct.showbase.ShowBase import ShowBase