Skip to content

Instantly share code, notes, and snippets.

@chk1
chk1 / gist:5391080
Last active May 11, 2022 10:55
simple edge detection in php
<?php
// input: r,g,b in range 0..255
function RGBtoHSV($r, $g, $b) {
$r = $r/255.; // convert to range 0..1
$g = $g/255.;
$b = $b/255.;
$cols = array("r" => $r, "g" => $g, "b" => $b);
asort($cols, SORT_NUMERIC);
$min = key(array_slice($cols, 1)); // "r", "g" or "b"
$max = key(array_slice($cols, -1)); // "r", "g" or "b"
@chk1
chk1 / vhost.conf
Last active February 14, 2016 19:04
Campusplan / AngularJS single page configuration using nginx & php5-fpm
server {
listen 80;
root /var/www/campusplan/app;
server_name campusplan.example.com;
index index.html index.php;
gzip on;
gzip_types application/x-javascript text/css;
// ==UserScript==
// @name YouTube HTML5 AutoPause
// @namespace https://greasyfork.org/en/users/13981-chk1
// @description Automatically pause YouTube HTML5 videos on Youtube
// @include https://*.youtube.com/watch*
// @include http://*.youtube.com/watch*
// @version 0.3
// @grant none
// @run-at document-end
// ==/UserScript==
<!DOCTYPE HTML>
<html>
<head>
<title>...</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
html, body, #watercup {
margin:0;
padding:0;
width:100%;
@chk1
chk1 / __install-traccar.md
Last active April 20, 2022 00:41
Building/installing Traccar with a Maven Docker container

Installing Traccar via Docker

... without installing Maven on your computer. This process will use the Docker container maven:3.5-jdk-8-alpine instead of a local Maven installation.

I used Ubuntu 16.04 server with the NGINX webserver.

📢 Deprecation notice 2019-06-29 📢

Traccar can now be run in Docker without building it yourself, just get the container from Docker Hub: https://hub.docker.com/r/traccar/traccar/

@chk1
chk1 / gist:093041848ef3dcfe88b8013d6c59d81c
Last active January 3, 2018 13:55
Re-enabling hiberate on Ubuntu 16.04 by decrypting swap

Re-enabling hiberate on Ubuntu 16.04 by decrypting swap

You installed Ubuntu 16.04 and chose to "encrypt the /home partition", now your hibernate mode won't work.

That is because your swap partition is also encrypted now.

Steps

  1. sudo swapoff -a
  2. sudo cryptsetup remove /dev/mapper/cryptswap1
@chk1
chk1 / youtube-embedded.user.js
Last active October 12, 2023 15:27
Play embedded Youtube videos for two seconds
// ==UserScript==
// @name Play embedded Youtube videos for two seconds
// @version 1.0
// @grant none
// @include https://www.youtube.com/embed/*
// @include https://www.youtube-nocookie.com/embed/*
// ==/UserScript==
// I chose two seconds because that's how long the bottom bar with play/pause/time stays visible
// Once that bar disappears, the time won't update, and the script can't react to
@chk1
chk1 / README.md
Last active August 4, 2021 07:37
Drillisch/Winsim Mailbox Menü

Drillisch/Winsim Mailbox Menü

Beim Anhören einer Nachricht:

2 Nachricht löschen

Hauptmenü / nach dem Abhören aller Nachrichten:

4 Nachricht versenden
9 Konfiguration

@chk1
chk1 / B1W portscan.txt
Last active June 18, 2024 09:15
Blueskysea B1W portscan
$ nmap -p0- -v -A -T4 192.168.201.1
Starting Nmap 6.40 ( http://nmap.org ) at 2019-06-10 20:49 CEST
NSE: Loaded 110 scripts for scanning.
NSE: Script Pre-scanning.
Initiating Ping Scan at 20:49
Scanning 192.168.201.1 [2 ports]
Completed Ping Scan at 20:49, 0.01s elapsed (1 total hosts)
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
Initiating Connect Scan at 20:49
@chk1
chk1 / nginx-403.conf
Created June 29, 2019 14:35
Fail2ban filters
[Definition]
failregex = ^.*:[0-9]+ <HOST> - - \[.*\] "(GET|POST|HEAD).*HTTP.* (403|404)
^\d+\/\d+\/\d+ \d+:\d+:\d+ \[error\] \d+#\d+: \*\d+ access forbidden by rule, client: <HOST>, server:
ignoreregex =