Skip to content

Instantly share code, notes, and snippets.

View cvan's full-sized avatar
🚌
🌊

Christopher Van cvan

🚌
🌊
View GitHub Profile
@cvan
cvan / limd-build-macos.sh
Created March 11, 2024 21:58 — forked from LukeZGD/limd-build-macos.sh
Build libimobiledevice stack for macOS with ease
#!/bin/bash
# Adapted from
# https://gist.github.com/LukeZGD/0f5ba45494912c419f59bd8178ab57bd
# If you like this script and my work on libimobiledevice, please
# consider becoming a patron at https://patreon.com/nikias - Thanks <3
REV=1.0.10-cvan
export MACOSX_DEPLOYMENT_TARGET=10.13
@cvan
cvan / limd-build-macos.sh
Last active October 10, 2023 03:16 — forked from nikias/limd-build-macos.sh
Build libimobiledevice stack for macOS with ease
#!/bin/bash
# If you like this script and my work on libimobiledevice, please
# consider becoming a patron at https://patreon.com/nikias - Thanks <3
REV=1.0.12
if test -x "`which tput`"; then
ncolors=`tput colors`
if test -n "$ncolors" && test $ncolors -ge 8; then
# generated 2023-10-04, Mozilla Guideline v5.7, Caddy 2.1.1, intermediate configuration
# https://ssl-config.mozilla.org/#server=caddy&version=2.1.1&config=intermediate&guideline=5.7
# note that Caddy automatically configures safe TLS settings
# replace example.com with your domain name
example.com
# Due to a lack of DHE support, you -must- use an ECDSA cert to support IE 11 on Windows 7
tls {
protocols tls1.2 tls1.3
@cvan
cvan / mongodb-macos-launch-startup.md
Last active October 4, 2023 19:13
launch mongodb's mongod daemon on macOS boot

Edit the plist file

Add the following XML content to the plist file. Replace /usr/local/bin/mongod with the correct path to your MongoDB executable if it's different. You may also need to adjust other settings like the data directory or log paths.

Launch Terminal. Create this new file:

nano ~/Library/LaunchAgents/com.mongodb.mongod.plist

Paste the following:

@cvan
cvan / goa.sh
Created August 7, 2023 05:09
GitHub Org Archiver — using gh cli: https://cli.github.com
#!/bin/bash
NL=$'\n';
output_dir="$HOME/ghq/github.com";
repo_limit=100000;
org_slug="$1";
echo "<\!doctype html><html><meta charset='utf-8'><title>$org_slug</title></head><body><code><pre>$(gh repo list $org_slug --limit $repo_limit)</pre></code></body></html>""$NL" > index.html
@cvan
cvan / controlled.jsx
Created July 16, 2023 23:33
DecimalInput • react component - input field with 0.000 precision
import React, { useState } from 'react';
const DecimalInput = () => {
const [value, setValue] = useState('');
const handleInputChange = (event) => {
const newValue = event.target.value;
// If the new value is empty, or it matches the decimal pattern, update the value.
if (newValue === '' || /^-?\d*[.,]?\d{0,3}$/.test(newValue)) {
@cvan
cvan / mongodb_delete_all_collections_documents.md
Last active October 4, 2023 19:16
mongodb delete all documents in every collection
mongosh 'mongodb+srv://YOUR_MONGODB_ATLAS_URL.mongodb.net/' --apiVersion 1 --username YOUR_ADMIN_USERNAME
> Enter password:
(enter password)
@cvan
cvan / play_radiooooo_cli.md
Last active October 4, 2023 19:17
play radiooooo using a CLI on the command-line terminal

play radiooooo.com from the terminal

From the comfort of your desktop computer, would you like to play the lovely sounds of radiooooo.com without having to create an account, log in, and open your browser?

An awesome individual, @olshevskiy87, wrote a command-line interface (CLI) for radiooooo.com: goradiooooo

Paste this bash script in somewhere handy, such as ~/bin/rdio ($HOME/bin/rdio).

mkdir -p "$HOME/bin/";
@cvan
cvan / debug.css
Created May 4, 2023 08:22
css debug - with nested outlines for DOM levels
* {
outline: 2px dotted red;
}
* * {
outline: 2px dotted green;
}
* * * {
outline: 2px dotted orange;
@cvan
cvan / reusable-svgs-symbol-ref-by-id.md
Created April 19, 2023 02:36
reuse SVG multiple times on same web page

View DEMO

demo of rendering templated SVGs by defining the shape once

Creating SVG templated elements

Why? Less code is sent down the wire to the user ("the client," the browser). This means faster page load times since it's less code. As a principle, a smaller and flatter DOM structure is going to perform better in the browser. In general, the larger the DOM node tree, the slower, manipulations to the structure will be more expensive by the browser's layout system.