Skip to content

Instantly share code, notes, and snippets.

View detj's full-sized avatar
🖥️
deep into work

Debjeet Biswas detj

🖥️
deep into work
View GitHub Profile
@detj
detj / get-docker-image-ids.sh
Created November 15, 2023 10:40
get docker image ids
# grab list of image ids
docker images -a | tail -n+2 | awk '{print $3}'
# Explanation
#
# -n+2 removes the table header from the output
# awk '{print $3}' grabs the image column values
# Output
@detj
detj / repo-created-at.sh
Created November 14, 2023 07:40
get github repository creation date
# syntax
curl -s https://api.github.com/repos/<org>/<repo> | jq .created_at
# example
curl -s https://api.github.com/repos/PRQL/prql | jq .created_at
@detj
detj / default-domains.sh
Created November 5, 2023 13:28
Get list all domains supported by defaults
# get list all domains support by `defaults` and present as a list
defaults domains | sed 's/, /\n/g'
@detj
detj / public-ip.sh
Last active December 19, 2023 14:39
Get public IP
# may or may not work
dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
curl icanhazip.com
curl ifconfig.me
@detj
detj / disable-press-and-hold.sh
Created October 21, 2023 19:12
Disable ApplePressAndHold
# syntax to read
# defaults read <bundle-identifier> ApplePressAndHoldEnabled
# syntax to write
# defaults write <bundle-identifier> ApplePressAndHoldEnabled -bool false
# example command
defaults write com.electron.replit ApplePressAndHoldEnabled -bool false
@detj
detj / identifier.sh
Last active November 1, 2023 21:58
Find bundle identifier of a macOS app
# find the bundle identifier of Numbers app
codesign -dv /Applications/Numbers.app/
# explanation of the flags used
#
# -d, --display Display information about the code at the path(s) given.
# -v, --verify Requests verification of code signatures
# one line to directly extract the bundle identifier using [rg](https://github.com/BurntSushi/ripgrep)
codesign -dv /Applications/Numbers.app/ 2>&1 | rg '^Identifier=' --replace ""
@detj
detj / getElements.js
Created July 24, 2021 14:00
function that returns used elements in a document
function getElements({ sort = true } = {}) {
let elems = Array.from(document.getElementsByTagName("*")).map(
(e) => e.localName
);
let map = new Map();
for (let elem of elems) {
if (!map.has(elem)) {
map.set(elem, 1);
@detj
detj / exclude-one.js
Created October 24, 2019 09:26
return a new object excluding one key
const source = { a: 1, b: 2, c: 3 }
const toRemove = "c"
const { [toRemove]: toRemove, ...rest } = source
// rest will be { a: 1, b: 2 }
// source remains { a: 1, b: 2, c: 3}
@detj
detj / forward-proxy.js
Last active November 12, 2020 13:31
Forward proxy in Express
const http = require("http");
const express = require("express");
const app = express();
const HOST = "localhost";
const PORT = 4000;
const PROXY_PORT = 8080;
setupProxy();
@detj
detj / mac-wifi-pass.sh
Last active February 15, 2019 19:48
get wifi password
security find-generic-password -ga "SSID"