Skip to content

Instantly share code, notes, and snippets.

View moqmar's full-sized avatar

Moritz Marquardt moqmar

View GitHub Profile
@media print {
#st-container, #prk_responsive_menu, #unten { display: none; }
#prk_ajax_container { margin-left: 0; }
#sidebar { display: none; }
#centered_block { max-width: 100%; }
.twelve.columns.sidebarized { padding: 0; }
/* Steht sonst in der linken Seitenleiste: */
body:after { content: "Wortwuchs.net"; display: block; text-align: right; font-size: 10pt; color: #888; margin-right: 25px; }
}
@moqmar
moqmar / playground.html
Last active August 5, 2016 21:47
Shared via plgrnd.com
<!doctype html>
<meta charset="utf-8">
<style>
@import 'https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css';
@import 'https://fonts.googleapis.com/css?family=Fira+Sans';
body { margin: 0; padding: 25px; background: #f8f8f8; font-family: Fira Sans, sans-serif; }
/* ... */
</style>
@moqmar
moqmar / ses.js
Last active November 2, 2016 13:33
Simple Element Selection for JavaScript w/o jQuery
// Element Selection - _("#howcoolisthat") - https://gist.github.com/moqmar/55587fad606176fafbcf7777655f2fbe
// document.querySelector
window._ = document.querySelector.bind(document)
// document.querySelectorAll with callback
window.__ = function (selector, callback, element) {
var elements = Array.prototype.slice.call((element||document).querySelectorAll(selector));
if (typeof callback == "function")
for (var i = 0; i < elements.length; i++)
@moqmar
moqmar / keybase.md
Last active January 16, 2017 20:26

Keybase proof

I hereby claim:

  • I am moqmar on github.
  • I am momar (https://keybase.io/momar) on keybase.
  • I have a public key whose fingerprint is 8D0D F6B3 C0E7 963C 4DD8 3FFD 57C5 EC5D A3B7 595E

To claim this, I am signing this object:

@moqmar
moqmar / base.css
Last active January 23, 2017 15:03
base.css - Simple but beautiful styling for all basic HTML elements in ~5KB. Useful as a basic stylesheet to build upon.
/*
BASE.CSS
‾‾‾‾‾‾‾‾
Simple but beautiful styling for all basic HTML elements. Useful as a basic stylesheet to build upon.
Version 0.4
Created by Moritz Marquardt, mo-mar.de
Licensed under CC0 - https://creativecommons.org/publicdomain/zero/1.0/
Provided classes:
@moqmar
moqmar / leftpad.js
Last active February 13, 2017 16:36
Leftpad, as it has to be: simple, fast, flexible
// Leftpad - P(value, length, character, rightpad) - https://gist.github.com/moqmar/9ef4f0755d0a17b61458f35b91447bc1
function P(v,l,c,r) { v = v.toString(); while (v.length < l) v = r ? v + (c||0) : (c||0) + v; return v; }
// Usage: P(value, length, character, rightpad)
// P(25, 3) ➜ "025"
// P(1, 3, " ") ➜ " 1"
// P(25, 4, ".", true) ➜ "25.."
// public domain / cc0
@moqmar
moqmar / parent.js
Last active February 13, 2017 16:44
// Parent Elements - e.P("body") - https://gist.github.com/moqmar/0995cf6595201f7a062fb173cb4ab938
(function(E){E.matches||(E.matches=E.matchesSelector||E.msMatchesSelector||E.webkitMatchesSelector)})(Element.prototype)
Element.prototype.P = function(s) {
var e = this;
if (!s || typeof s == "number") for (var i = 0; i < (s || 1); i++) e = e ? e.parentElement : e;
else if (typeof s == "string") while (e && !e.matches(s)) e = e.parentElement;
else while (e && e != s) e = e.parentElement;
return e
}
@moqmar
moqmar / Responsive Modals.md
Last active May 8, 2017 19:04
Responsive Modals made purely with HTML & CSS

Responsive Modals made purely with HTML & CSS

…in less than half a kilobyte

All you need is the file modal.min.css and the following code:

<input id="helloworld" type="checkbox" hidden><div class="modal">
  <label for="helloworld"></label><!-- close modal on click -->
  <div><!-- modal contents -->
    <h1>Look at this awesomeness!</h1>
@moqmar
moqmar / select-on-click.js
Last active November 14, 2017 11:23
Select all text in an element
// Modified version of https://stackoverflow.com/a/987376
function selectText(el) {
if (!el) return;
var range, selection;
if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(el);
range.select();
} else if (window.getSelection) {
selection = window.getSelection();
@moqmar
moqmar / Dockerscript
Last active November 14, 2017 11:24
Script for simple management and updating of docker containers. Like docker-compose, but more flexible and with single-command upgrade functionality.
#!/bin/sh
# ./Dockerscript <prefix>
name=helloworld
[ -n "$PREFIX" ] && prefix=-$PREFIX
set -e
start() {
docker network create --driver bridge $name$prefix
docker run -id --restart=always --network=$name$prefix -v "$PWD/files:/data" --name=$name$prefix-main "$@" hello-world