Skip to content

Instantly share code, notes, and snippets.

View mvsde's full-sized avatar
🏳️‍⚧️
Protect trans kids!

Fynn Becker mvsde

🏳️‍⚧️
Protect trans kids!
View GitHub Profile
@mvsde
mvsde / svg-url.scss
Last active May 15, 2017 18:22
Cross-browser inline SVG function
// SVG URL
//
// Generate an escaped SVG for data URIs.
//
// Usage:
// .selector {
// background-image: svg-url('<svg>…</svg>');
// }
//
// Source:
@mvsde
mvsde / add-event-listener-once.js
Last active June 30, 2021 07:55
JavaScript Collapse
/**
* Modern browsers support the `once` option for event listeners:
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters
*/
module.exports = function(target, type, callback) {
let eventWrapper = function(event) {
target.removeEventListener(type, eventWrapper);
callback(event);
};
@mvsde
mvsde / fluid-type.scss
Last active July 3, 2023 00:31
Fluid typography Sass mixin
// Modern browsers have support for the CSS clamp function:
// https://developer.mozilla.org/en-US/docs/Web/CSS/clamp()
// Source: https://css-tricks.com/snippets/css/fluid-typography/
@mixin fluid-type($min-font-size, $max-font-size, $min-vw: $breakpoint-min, $max-vw: $breakpoint-max) {
$u1: unit($min-vw);
$u2: unit($max-vw);
$u3: unit($min-font-size);
$u4: unit($max-font-size);
@mvsde
mvsde / sr-only.css
Last active January 7, 2020 15:39
Hide element visually but keep it in accessibility tree
/**
* Visually hides elements but keeps them accessible for screen readers and
* keyboard users.
*
* Source:
* https://allyjs.io/tutorials/hiding-elements.html#2017-edition-of-visuallyhidden
*/
.sr-only:not(:focus):not(:active) {
position: absolute;
@mvsde
mvsde / event-bus.js
Last active June 30, 2021 07:52
Subscribe / Publish pattern
/**
* Use Mitt instead: https://github.com/developit/mitt
*/
const EventBus = {
topics: {},
subscribe: function (topic, listener) {
// Create topic if not yet created
if (!this.topics[topic]) {
@mvsde
mvsde / disable-auto-restart.sh
Last active August 20, 2018 05:11
Stop Docker auto restart on all containers
# Source:
# https://github.com/moby/moby/issues/10032#issuecomment-310023443
docker stop $(docker ps -a -q) & docker update --restart=no $(docker ps -a -q)
@mvsde
mvsde / android-volume-steps.md
Last active April 14, 2024 00:04
Android Volume Steps

Android Volume Steps

Warning

This is a rather old guide and may or may not work with modern versions of Android.

Connect through ADB

  1. Boot into TWRP
  2. Connect device to computer
  3. Terminal: List devices with adb devices
@mvsde
mvsde / mirror-website.sh
Last active January 13, 2019 10:14
Download mirror of a website
wget --mirror --page-requisites --adjust-extension --convert-links --no-clobber --domains=domain.tld https://domain.tld
@mvsde
mvsde / script.sh
Created February 21, 2019 12:12
Re-enable macOS subpixel antialiasing
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
@mvsde
mvsde / json-stringify.scss
Last active August 26, 2019 12:58
Naive JSON.stringify() in Sass (handles strings only)
@function json-stringify ($map) {
$result: '{';
@each $key, $value in $map {
$result: $result + '"#{$key}":';
@if type-of($value) == 'map' {
$result: $result + json-stringify($value);
} @else {
$result: $result + '"#{$value}"';