Skip to content

Instantly share code, notes, and snippets.

View exiguus's full-sized avatar
🍍

Simon Gattner exiguus

🍍
View GitHub Profile
@exiguus
exiguus / useNetwork.ts
Created October 25, 2020 09:59
NetworkInfo Hook
import { useState, useEffect } from 'react'
// Network Information API
// NetworkInfo https://wicg.github.io/netinfo/
// https://caniuse.com/netinfo
enum ConnectionType {
'bluetooth',
'cellular',
'ethernet',
@exiguus
exiguus / currying.js
Last active February 23, 2021 10:44
Partial application and Currying in JavaScript
// JavaScript
//
// Partial application
// prefilling argument
const add = (...args) => [...args].reduce((a, b) => a + b)
const addMore = add.bind(undefined, 3, 5, 10)
console.log('bind addMore(2)', addMore(2)) // bind addMore(2) 20
const mergeObject = (a, b) => Object.freeze({
@exiguus
exiguus / colors.ts
Created December 28, 2021 23:31
Generate HSL or RGB colors
export function getRandomInt(min: number, max: number): number {
min = Math.ceil(min)
max = Math.floor(max)
return Math.floor(Math.random() * (max - min) + min)
}
const getRandomRGBColors = (count = 16) => {
const colors: [number, number, number][] = []
const ranges = [255, 192, 128, 64, 32]
for (let i = 0; i < ranges.length; ) {
@exiguus
exiguus / firefox-nightly-install.bash
Created November 18, 2024 19:52
Install and Update Firefox Nightly on Linux (Debian) parallel to Firefox ESR
#!/bin/bash
# Variables
NIGHTLY_DIR="$HOME/firefox-nightly"
NIGHTLY_PROFILE_DIR="$HOME/.mozilla/firefox-nightly-profile"
DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os=linux64&lang=en-US"
DESKTOP_FILE="$HOME/.local/share/applications/firefox-nightly.desktop"
BIN_DIR="$HOME/.local/bin"
EXECUTABLE="$BIN_DIR/firefox-nightly"
TEMP_FILE="$HOME/Downloads/firefox-nightly.tar.bz2"