Skip to content

Instantly share code, notes, and snippets.

View TobleMiner's full-sized avatar
🔥

Tobias Schramm TobleMiner

🔥
  • Kiel
View GitHub Profile
@TobleMiner
TobleMiner / gist:aab86ca5958e7363afb7
Last active January 29, 2016 17:51
Node.js buffer bitshift
Buffer.prototype.bshiftr = function(num, resize)
{
if(typeof resize == 'undefined')
resize = false;
var byte_offset = Math.floor(num / 8);
var buff = new Buffer(this.length + (resize ? byte_offset : 0));
buff.fill(0);
if(num % 8 == 0)
{
this.copy(buff, byte_offset, 0, this.length);
@TobleMiner
TobleMiner / gist:3a077031ddf442461bf3
Created February 18, 2015 23:00
Shell fullscreen
#!/bin/bash
x_width=$(xrandr --current | grep '* ' | uniq | awk '{print $1}' | cut -d 'x' -f1)
x_height=$(xrandr --current | grep '* ' | uniq | awk '{print $1}' | cut -d 'x' -f2)
chromium&
pid=$!
while [ "$WID" == "" ]; do
WID=$(wmctrl -lp | grep $pid | cut "-d " -f1)
@TobleMiner
TobleMiner / gist:cde1825190f66893710d
Last active August 29, 2015 14:16
Dmesg human readable timestamps
#!/usr/bin/perl
use strict;
use warnings;
my @dmesg_new = ();
my $dmesg = "/bin/dmesg";
my @dmesg_old = `$dmesg`;
my $now = time();
my $uptime = `cat /proc/uptime | cut -d"." -f1`;
@TobleMiner
TobleMiner / gist:d0b7049db531e631e4fd
Last active August 29, 2015 14:16
Apache SSLEngine config TLS only, !RC4, HSTS
SSLEngine On
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
SSLCertificateFile /etc/ssl/certs/certificate.crt
SSLCertificateKeyFile /etc/ssl/private/privatekey.key
SSLCertificateChainFile /etc/ssl/ca/itermediate-cert.pem
SSLCACertificateFile /etc/ssl/ca/ca.pem
@TobleMiner
TobleMiner / gist:65625a31e2ccd1909620
Created March 4, 2015 17:27
Apache mod_rewrite HTTP -> HTTPS redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
local window = tui.Window.create(uiManager)
window:setSize(39, 26)
local label = tui.Label.create(uiManager)
label:setPos(2, 3)
label:setText("Hello World")
label:setOnclick(function() print("Click") end)
window:addChild(label)
local layout = tui.ReactorLayout.create(uiManager)
layout:setPos(4, 5)
window:addChild(layout)
@TobleMiner
TobleMiner / Schrödingers icvpn
Created November 23, 2015 23:00
Schrödingers icvpn
tobias@Twily:~$ sudo ping6 fda1:384a:74de:4242:16cc:20ff:fe5e:7462
PING fda1:384a:74de:4242:16cc:20ff:fe5e:7462(fda1:384a:74de:4242:16cc:20ff:fe5e:7462) 56 data bytes
64 bytes from fda1:384a:74de:4242:16cc:20ff:fe5e:7462: icmp_seq=6912 ttl=60 time=81.9 ms
64 bytes from fda1:384a:74de:4242:16cc:20ff:fe5e:7462: icmp_seq=20906 ttl=60 time=96.2 ms
64 bytes from fda1:384a:74de:4242:16cc:20ff:fe5e:7462: icmp_seq=21991 ttl=60 time=88.8 ms
64 bytes from fda1:384a:74de:4242:16cc:20ff:fe5e:7462: icmp_seq=34494 ttl=60 time=95.3 ms
^C
--- fda1:384a:74de:4242:16cc:20ff:fe5e:7462 ping statistics ---
39486 packets transmitted, 4 received, 99% packet loss, time 39498138ms
rtt min/avg/max/mdev = 81.948/90.589/96.224/5.743 ms
@TobleMiner
TobleMiner / nein.java
Created January 13, 2016 19:16
ARGB to RGB blend
public static int convertARGBtoRGB(int argbValue)
{
int rgb = 0;
// Extract bit 24 - 31 and discard sign (& 0xFF)
double alpha = ((argbValue >> 24) & 0xFF) / 255d;
for(int i = 0; i <= 16; i += 8)
{
// Extract color channel
int channel = argbValue >> i & 0xFF;
@TobleMiner
TobleMiner / uppercase_to_lowercase.s
Last active January 14, 2016 17:55
DLX asm ASCII upper case to lower case
// Registers
// R1: Length of text and decrementing counter (Assignment doesn't indicate that it must be preseved)
// R2: Temp register
// R3: Magic value used to add 32 to all bytes in a word
// Memory
// 1000..1000 + r1 : ASCII input
// 2000..2000 + r1 : ASCII output
START:
@TobleMiner
TobleMiner / RectangleDIstanceCalculator.java
Created January 20, 2016 13:34
Chris RectangleDistanceCalculator
package test.chris;
import java.awt.geom.Rectangle2D;
public class RectangleDistanceCalculator
{
// PRIVATE METHODS
// TESTMETHODE