Skip to content

Instantly share code, notes, and snippets.

Avatar
Build failed

Michael Neu michaelneu

Build failed
View GitHub Profile
@michaelneu
michaelneu / BackgroundWorker.java
Created May 5, 2015
A simple implementation of C#'s BackgroundWorker-class in Java for JavaFX.
View BackgroundWorker.java
import javafx.application.Platform;
/**
* A simple replacement for the C# BackgroundWorker-class for JavaFX
* @author minedev
*/
public abstract class BackgroundWorker {
private Thread thread;
private boolean workerStarted;
@michaelneu
michaelneu / Debouncer.ts
Created Aug 11, 2016
Typescript implementation of a debouncer using rxjs Observable
View Debouncer.ts
import { Observable } from "rxjs/Observable";
import { Observer } from "rxjs/Observer";
import "rxjs/add/operator/debounceTime";
/**
* Class representing a debouncer to delay incoming events.
*/
export default class Debouncer<T> {
private observer: Observer<T>;
@michaelneu
michaelneu / keybase.md
Created Aug 22, 2016
Keybase GitHub Proof
View keybase.md

Keybase proof

I hereby claim:

  • I am michaelneu on github.
  • I am michaelneu (https://keybase.io/michaelneu) on keybase.
  • I have a public key ASCCx7GrQCMSwOCudZ16kqcvRs3YXa_DYbBMSgFfTTk35Ao

To claim this, I am signing this object:

@michaelneu
michaelneu / howto.java
Created Jan 16, 2018
An example integration for OTH Regensburg's software development course (see https://github.com/michaelneu/gorillamail)
View howto.java
// step 1: create your mail
final Mail mail = new Mail();
// step 2: add your credentials
final User user = new User();
user.setEmail("barb@gorillamail.space");
user.setPassword("p4ssword!");
// step 3: set your template
final Template template = new Template();
@michaelneu
michaelneu / README.md
Last active Nov 9, 2018
Create a map for IP addresses
View README.md

geocode.py

Use this file to geocode IPs from logfiles and draw them on a map.

How to use it

This script requires geocoder to be installed, so setup a virtualenv:

$ virtualenv --python=python3 venv
@michaelneu
michaelneu / arch-asus-fancontrol.py
Created Dec 28, 2018
Control the fan in ASUS laptops via ACPI
View arch-asus-fancontrol.py
#!/usr/bin/env python2
import sys
import os
def call_acpi(command):
with open('/proc/acpi/call', 'w') as acpi_call:
acpi_call.write(command)
# Response
View arch-pwm-fan.py
#!/usr/bin/python2
def set_speed(pwm, speed):
speed = max(0, min(100, speed))
speed = 2.55 * speed
speed = int(speed)
with open("/sys/class/hwmon/hwmon1/pwm" + str(pwm), "w") as f:
f.write(str(speed))
@michaelneu
michaelneu / harold-scraper.py
Last active Jan 3, 2019
Scrape all images from hide the pain harold
View harold-scraper.py
#!/usr/bin/env python3
import urllib.request
import os
import re
import sys
from concurrent.futures import ProcessPoolExecutor as PoolExecutor, as_completed
from PIL import Image
image_page_link_pattern = re.compile(r"src=\"https:\/\/thumbs\.dreamstime\.com\/t\/([^\"]+)")
@michaelneu
michaelneu / drag-n-drop-hook.ts
Created Jan 5, 2019
TypeScript React hook for drag'n'drop on elements
View drag-n-drop-hook.ts
import { useState } from "react";
export const useDragAndDrop = <T extends HTMLElement>() => {
const [isDragging, setIsDragging] = useState(false);
const [innerOffsetX, setInnerOffsetX] = useState(0);
const [innerOffsetY, setInnerOffsetY] = useState(0);
const start = (event: React.MouseEvent<T, MouseEvent>) => {
const element = event.target as T;
const { left, top } = element.getBoundingClientRect();
@michaelneu
michaelneu / button.js
Last active Jan 9, 2019
Color context sensitive styled-components HoC
View button.js
import styled from "styled-components";
export const withButtonStyle = (component) => styled(component)`
position: relative;
display: block;
width: 100%;
padding: 0.5rem 2rem;
color: currentColor;