Skip to content

Instantly share code, notes, and snippets.

@sidisinsane
sidisinsane / _component.scss
Created May 12, 2021
Simple themable Sass Mixin using Dart Sass >=1.23.0
View _component.scss
// Requires Dart Sass >=1.23.0 (npm i -D sass@">=1.23.0 < 1.33")
// Set overridable default variables/maps.
$-color: red;
/// Configuration mixin for component mixin.
/// Sets overridable defaults – themable.
///
/// @name component.configure
/// @group components
@sidisinsane
sidisinsane / vpn.md
Created Aug 29, 2020 — forked from joepie91/vpn.md
Don't use VPN services.
View vpn.md

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@sidisinsane
sidisinsane / get-object-fit-data.js
Created Apr 26, 2020
Calculates Dimensions and Ratio for an Object to fit in a Container
View get-object-fit-data.js
const getObjectFitData = (obj, container, cover=true) => {
let result = {};
const ratioX = container.width / obj.width;
const ratioY = container.height / obj.height;
const ratioFit = cover ? Math.max(ratioX, ratioY) : Math.min(ratioX, ratioY);
result.ratio = Math.ceil(ratioFit * 100) / 100;
result.width = Math.ceil(obj.width * result.ratio);
result.height = Math.ceil(obj.height * result.ratio);
@sidisinsane
sidisinsane / poster.command
Last active Apr 15, 2020
Creates a poster from a given mp4 frame.
View poster.command
#!/usr/bin/env bash
# Creates a poster from a given mp4 frame.
# 1. Get FFmpeg (https://evermeet.cx/ffmpeg/) and install it
# 2. Place this script within your mp4 folder
# 3. Make it executable: chmod +x path/to/poster.command
# 4. Execute it by doubleclicking this file
dir=$(dirname $(realpath -s $0))
echo "Enter filename without extension (i.e. my-awesome-video)."
read name
echo "Enter timestamp (HH:MM:SS.MM) of frame to create poster from."
@sidisinsane
sidisinsane / git-clean.md
Created Apr 6, 2020
Remove all untracked Git files and directories
View git-clean.md

Preview files and directories that would be removed from git clean -fd

git clean -nd

Remove all untracked files and directories ('-f' is force, '-d' is remove directories)

git clean -fd
@sidisinsane
sidisinsane / git-branch-to-favicon.js
Created Apr 4, 2020
Creates a favicon.svg from the current Git Branch
View git-branch-to-favicon.js
const { execSync } = require('child_process')
const { createHash } = require('crypto')
const invertColor = require('invert-color')
const fs = require('fs')
const path = require('path')
/**
* Returns numeronym string
* @param str
* @returns {*}
View create-webm.sh
#!/usr/bin/env bash
shopt -s nullglob nocaseglob extglob
for file in src/assets/videos/*.mp4; do
name="${file%%.*}"
if [ -f "$name-1280x720-1500k.webm" ]; then
echo "$name-1280x720-1500k.webm exists"
else
ffmpeg \
-i "$file" -vn -acodec libvorbis -ab 128k -dash 1 "$name-audio.webm" && \
ffmpeg \
View create-webp.sh
#!/usr/bin/env bash
quality=80
shopt -s nullglob nocaseglob extglob
for file in src/assets/img/**/*.@(jpg|jpeg|png); do
if [ -f "${file%.*}.webp" ]; then
echo "${file%.*}.webp exists"
else
cwebp -q $quality "$file" -o "${file%.*}.webp"
fi
done
@sidisinsane
sidisinsane / compress-mp4.sh
Created Apr 2, 2020
Compress MP4 with FFmpeg
View compress-mp4.sh
ffmpeg -i source.mp4 -vcodec h264 -b:v 1000k -acodec mp3 target.mp4
@sidisinsane
sidisinsane / convert-mp4-to-ogv.sh
Created Mar 30, 2020
Convert MP4 to OGV with FFmpeg
View convert-mp4-to-ogv.sh
ffmpeg -i source.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 target.ogv