Skip to content

Instantly share code, notes, and snippets.

import { LRUCache } from './lru-cache.js';
const FirebaseQueryAction = {
snapshotReceived: 'FIREBASE_QUERY_SNAPSHOT_RECEIVED',
created: 'FIREBASE_QUERY_CREATED'
};
const FirebaseQueryActionCreatorCache = (maxRealtimeQueries = 10) => {
const cache = new LRUCache(
maxRealtimeQueries,
@hannesbe
hannesbe / add-connexeon-vpn.ps1
Last active January 31, 2018 17:32
Powershell script to create PPTP VPN Connexeon in Windows, for all users & no additional login required client has joined AD
Add-VpnConnection -Name "VPN Connexeon" -ServerAddress "vpn.connexeon.com" -TunnelType Pptp -EncryptionLevel Required -AuthenticationMethod MSChapv2 -AllUserConnection -RememberCredential -PassThru -UseWinlogonCredential
Set-VpnConnection "VPN Connexeon" -AllUserConnection -SplitTunneling $True
Add-VpnConnectionRoute -ConnectionName "VPN Connexeon" -DestinationPrefix 10.0.0.0/12 -PassThru
Add-VpnConnectionRoute -ConnectionName "VPN Connexeon" -DestinationPrefix 10.111.0.0/16 -PassThru
Add-VpnConnectionRoute -ConnectionName "VPN Connexeon" -DestinationPrefix 10.50.0.0/16 -PassThru
@marcysutton
marcysutton / accessible-uis.md
Last active June 25, 2018 14:32
Accessible UIs - State of A11y

How to accessibility!

Definition of done

Education

  • Awareness
  • Design and UX
@guixxx
guixxx / lrc-autoload.lua
Last active December 1, 2019 22:22
(DEPRECATED) Automatically loads lyric (.lrc) files to mpv if they're found
-- NOTE: This script is no longer necessary as of mpv 0.30.0!
loaded = false
function search_and_load_lrc()
local lrc_path = ext2lrc(mp.get_property("path"))
local file = io.open(lrc_path, "r")
if file ~= nil then
io.close(file)
@yangshun
yangshun / arrayToCSV.js
Last active January 18, 2021 15:22
Converts a 2D array into a CSV file
function arrayToCSV (twoDiArray) {
// Modified from: http://stackoverflow.com/questions/17836273/
// export-javascript-data-to-csv-file-without-server-interaction
var csvRows = [];
for (var i = 0; i < twoDiArray.length; ++i) {
for (var j = 0; j < twoDiArray[i].length; ++j) {
twoDiArray[i][j] = '\"' + twoDiArray[i][j] + '\"'; // Handle elements that contain commas
}
csvRows.push(twoDiArray[i].join(','));
}
@neumond
neumond / qtileconfig.py
Last active August 30, 2021 14:36
My qtile config
import pickle
import weakref
from contextlib import contextmanager, suppress
from datetime import datetime
from itertools import islice
from logging import getLogger
from pathlib import Path
from libqtile import bar, hook, layout, widget
from libqtile.command import lazy
@chriszarate
chriszarate / getTextNodesBetween.js
Last active April 1, 2023 13:45
Native JavaScript function to get all *text* nodes contained in a selection object.
// Get all *text* nodes contained in a selection object.
// Adapted from code by Tim Down.
// http://stackoverflow.com/questions/4398526/how-can-i-find-all-text-nodes-between-to-element-nodes-with-javascript-jquery
function getTextNodesBetween(selection) {
var range = selection.getRangeAt(0), rootNode = range.commonAncestorContainer,
startNode = range.startContainer, endNode = range.endContainer,
startOffset = range.startOffset, endOffset = range.endOffset,
pastStartNode = false, reachedEndNode = false, textNodes = [];
function getTextNodes(node) {
var val = node.nodeValue;
@pfig
pfig / mkfavicon.sh
Created February 12, 2012 12:01
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png

Using server-sent events

Why and how?

  • Documentation: https://web.dev/articles/eventsource-basics
  • Use case: broadcasting data from server to browsers
  • Benefits:
    • Easy to understand and implement (only a few lines of code)
    • No library is needed
  • Can use same HTTP(S) authentication as elsewhere in the app (which can’t be done with websockets)
@inhies
inhies / twrp.sh
Last active May 16, 2024 14:12
Creates TWRP compatible backups over USB using ADB without any files ever touching your SD card.
#!/bin/bash
#
# Version 1.4
#
# twrp.sh -- a TWRP compatible backup script for your computer
# Brought to you by inhies
#
# This script creates TWRP compatible backups over usb using adb and magikz
# By default it makes a folder in the standard TWRP date--time format (I think)
# To restore these backups, place the folder in /sdcard/TWRP/BACKUPS/<serialnumber>/