Skip to content

Instantly share code, notes, and snippets.

View malte-j's full-sized avatar
❤️
🍍🍕

Malte Janßen malte-j

❤️
🍍🍕
View GitHub Profile
@malte-j
malte-j / 2DArray.js
Created September 21, 2017 15:33
JS 2D Array
function Create2DArray(rows, columns) {
var arr = [];
for (var i = 0; i < rows; i++) {
var col = [];
for (var j = 0; j < columns; j++){
col[j] = 0;
}
arr[i] = col;
}
return arr;
@malte-j
malte-j / fullscreen.js
Created October 21, 2017 15:58
Fullscreen elements using js
function calcVH () {
var vH = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
document.querySelector('body').setAttribute("style", "height:" + vH + "px;");
}
window.onload = calcVH();
window.addEventListener('onorientationchange', calcVH, true);
window.addEventListener('resize', calcVH, true);
const request = require('request');
// Request Header
var headers = {
'User-Agent': 'Secret Agent/0.0.1',
'Content-Type': 'application/x-www-form-urlencoded'
}
// Liste der comments
const comments = [
@malte-j
malte-j / currentYear.js
Created January 3, 2018 22:12
appends the current year to all elements with the '.currYear' class
// append the current year to all elements with the '.currYear' class
document.querySelectorAll('.currYear').forEach(node => node.textContent += (new Date()).getFullYear())
@malte-j
malte-j / library-example.js
Created February 11, 2018 20:18
Require Example
// JSON Objekt mit text Attribut
let data = {
text: "lorem ipsum"
}
// gibt den Text zurück
module.exports.getText = () => data.text;
// setzt den Text
module.exports.setText = newText => data.text = newText;
fetch('/api/open', {
method: "POST",
body: JSON.stringify({
token: idToken
}),
headers: {
"Content-Type": "application/json"
}
})
@malte-j
malte-j / config.sh
Created April 10, 2018 20:03
Open Gnome Settings On i3
#!/bin/bash
env XDG_CURRENT_DESKTOP=GNOME gnome-control-center
import subprocess, time, os
// Startet vlc im Vollbild ohne Interface und in Dauerschleife
command = ['cvlc', '-f', '-L', '--no-video-title-show', '/home/malte/Videos']
// Gibt das Display vor, auf dem das VLC-Fenster geöffnet wird, an
environment = dict(os.environ, DISPLAY=":0")
// Startet den VLC Prozess
vlc = subprocess.Popen(command, env=environment)
@malte-j
malte-j / 10-motd
Created October 2, 2018 22:30
MOTD for Mazebot, put this in /etc/update-motd.d/
#!/bin/sh
upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
secs=$((${upSeconds}%60))
mins=$((${upSeconds}/60%60))
hours=$((${upSeconds}/3600%24))
days=$((${upSeconds}/86400))
UPTIME=`printf "%dd %02dh %02dm %02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
@malte-j
malte-j / putIp.sh
Created January 11, 2019 20:47
Upload current IP to malts.me, using the client's hostname. Best run as cronjob
#!/bin/bash
ip addr >> $(hostname).txt
scp $(hostname).txt malts.me:~/ips
rm $(hostname).txt