Skip to content

Instantly share code, notes, and snippets.

View scsskid's full-sized avatar
:octocat:

Benedikt Gregor scsskid

:octocat:
View GitHub Profile
@scsskid
scsskid / postgres.md
Last active September 1, 2021 15:28
Postgres Cheatsheet #postgres #ubuntu

psql

Connect to Database

\c [databasename]
//src: https://github.com/swup/swup/blob/master/src/helpers/getCurrentUrl.js
const getCurrentUrl = () => {
return window.location.pathname + window.location.search;
};
export default getCurrentUrl;
@scsskid
scsskid / getDataFromHtml.js
Last active September 1, 2021 14:53
[getDataFromHtml] #dom #helpers
//Src: https://github.com/swup/swup/blob/master/src/helpers/getDataFromHtml.js
import { queryAll } from '../utils';
const getDataFromHtml = (html, containers) => {
let fakeDom = document.createElement('html');
fakeDom.innerHTML = html;
let blocks = [];
for (let i = 0; i < containers.length; i++) {
@scsskid
scsskid / docker-personal-cheatsheet.md
Last active February 15, 2023 18:16
Docker Personal Cheatcheet | #bash #docker

Docker Personal Cheatsheet

remove all containers

docker rm -f $(docker ps -aq)

Get ip address of container

@scsskid
scsskid / git-remove.sh
Created January 29, 2021 20:35
[git remove from history] #bash #git
# src: https://stackoverflow.com/a/17824718/2823589
git filter-branch --tree-filter "rm -rf node_modules" --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
echo node_modules/ >> .gitignore
git add .gitignore
git commit -m 'Removing node_modules from git history'
git gc
git push origin master --force
@scsskid
scsskid / youtubedl.sh
Last active June 30, 2021 10:56
[Youtube DL] #bash
# best audio
youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata
# best video and audio
youtube-dl -f best <video link>
# If you encounter any error during the muxing process or an issue with the video quality selection, you can use one of the following commands:
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 <video link>
# optional: --yes-playlist
@scsskid
scsskid / style.css
Created January 12, 2021 11:36
[Colorize iOS Status Bar] #ios #pwa
body:before {
content: '';
display: block;
position: fixed;
top: 0;
z-index: 7;
left: 0;
right: 0;
height: env(safe-area-inset-top);
width: 100%;
@scsskid
scsskid / sw-fetch-handler.js
Created December 21, 2020 16:30
[SW Fetch handler async/await sytnax] #serviceworker
addEventListener('fetch', event => {
// Prevent the default, and handle the request ourselves.
event.respondWith(async function() {
// Try to get the response from a cache.
const cachedResponse = await caches.match(event.request);
// Return it if we found one.
if (cachedResponse) return cachedResponse;
// If we didn't find a match in the cache, use the network.
return fetch(event.request);
}());
@scsskid
scsskid / sw.js
Last active December 16, 2020 13:40
[ServiceWorker Delete Caches which arent in list] src: https://developers.google.com/web/fundamentals/primers/service-workers/#update-a-service-worker #serviceworker
self.addEventListener('activate', function(event) {
var cacheAllowlist = ['pages-cache-v1', 'blog-posts-cache-v1'];
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.map(function(cacheName) {
if (cacheAllowlist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
@scsskid
scsskid / sw.js
Last active December 21, 2020 16:38
[Random Service Worker Examples] #serviceworker
//src: https://github.com/tretapey/svelte-pwa/blob/master/public/service-worker.js
'use strict';
// Update cache names any time any of the cached files change.
const CACHE_NAME = 'static-cache-v1';
// Add list of files to cache here.
const FILES_TO_CACHE = [
'/offline.html',