Skip to content

Instantly share code, notes, and snippets.

View michaelneu's full-sized avatar
Build failed

Michael Neu michaelneu

Build failed
View GitHub Profile
@michaelneu
michaelneu / Jenkinsfile
Created August 10, 2018 06:53
docker-compose configuration and Jenkinsfile to run builds in Docker containers
stage('Build') {
node (label: 'linux') {
checkout scm
docker.image('node:alpine').inside {
sh 'yarn install'
sh 'yarn build'
}
}
}
@michaelneu
michaelneu / button.js
Last active January 9, 2019 11:01
Color context sensitive styled-components HoC
import styled from "styled-components";
export const withButtonStyle = (component) => styled(component)`
position: relative;
display: block;
width: 100%;
padding: 0.5rem 2rem;
color: currentColor;
@michaelneu
michaelneu / drag-n-drop-hook.ts
Created January 5, 2019 14:41
TypeScript React hook for drag'n'drop on elements
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 / harold-scraper.py
Last active January 3, 2019 16:15
Scrape all images from hide the pain harold
#!/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\/([^\"]+)")
#!/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 / arch-asus-fancontrol.py
Created December 28, 2018 20:16
Control the fan in ASUS laptops via ACPI
#!/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
@michaelneu
michaelneu / howto.java
Created January 16, 2018 11:51
An example integration for OTH Regensburg's software development course (see https://github.com/michaelneu/gorillamail)
// 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 / keybase.md
Created August 22, 2016 21:29
Keybase GitHub Proof

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 / Debouncer.ts
Created August 11, 2016 13:08
Typescript implementation of a debouncer using rxjs Observable
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 / BackgroundWorker.java
Created May 5, 2015 16:07
A simple implementation of C#'s BackgroundWorker-class in Java for JavaFX.
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;