Skip to content

Instantly share code, notes, and snippets.

View krishnaTORQUE's full-sized avatar
💤
Dreaming ...

Krishna Torque krishnaTORQUE

💤
Dreaming ...
View GitHub Profile
@pydevops
pydevops / gke-gce-cloud-armor-lb.sh
Created December 7, 2021 23:42 — forked from mikesparr/gke-gce-cloud-armor-lb.sh
Example Cloud Armor policies protecting Google HTTPS Global Load Balancer in front of GCE instance group and GKE cluster
#!/usr/bin/env bash
# REF: https://cloud.google.com/armor/docs/integrating-cloud-armor#with_ingress
# REF: https://cloud.google.com/armor/docs/configure-security-policies
# REF: https://cloud.google.com/iap/docs/load-balancer-howto
# REF: https://cloud.google.com/sdk/gcloud/reference/compute/url-maps/add-path-matcher
# REF: https://cloud.google.com/load-balancing/docs/https/setting-up-url-rewrite
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active June 15, 2024 04:54
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@sindresorhus
sindresorhus / esm-package.md
Last active June 29, 2024 11:18
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@IvoPereira
IvoPereira / pwaDetector.js
Last active June 3, 2024 11:03
Detect if a PWA is installed (iOS Standalone, Trusted Web App, Chrome PWA)
function isPWA() {
return window.navigator.standalone == true || // iOS PWA Standalone
document.referrer.includes('android-app://') || // Android Trusted Web App
["fullscreen", "standalone", "minimal-ui"].some(
(displayMode) => window.matchMedia('(display-mode: ' + displayMode + ')').matches
) // Chrome PWA (supporting fullscreen, standalone, minimal-ui)
}
console.log(isPWA()) // true
@donrestarone
donrestarone / config.txt
Created March 17, 2020 19:38
a sample config.txt for dual hdmi raspberry pi 4 (use this fix if your raspberry pi 4 is not sending a video signal to your monitor)
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
@antoinerousseau
antoinerousseau / .eslintrc.js
Last active December 2, 2021 19:48
React Eslint config with TypeScript and Prettier
// yarn add typescript
// yarn add -D eslint prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks @typescript-eslint/parser @typescript-eslint/eslint-plugin
// yarn add -D @types/react @types/react-dom
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["react", "react-hooks", "prettier"],
extends: ["plugin:react/recommended", "plugin:prettier/recommended"],
parserOptions: {
ecmaVersion: 2018,
@Tras2
Tras2 / cloudflare-ddns-update.sh
Last active May 31, 2024 11:55
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@chetanppatil
chetanppatil / install-sonar-scanner.sh
Last active December 28, 2023 04:31
Install sonar-scanner in linux mint, ubuntu...
#!/bin/bash
cd /tmp || exit
echo "Downloading sonar-scanner....."
if [ -d "/tmp/sonar-scanner-cli-4.7.0.2747-linux.zip" ];then
sudo rm /tmp/sonar-scanner-cli-4.7.0.2747-linux.zip
fi
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
echo "Download completed."
@wirwolf
wirwolf / ecosystem.json
Created June 14, 2018 20:13
pm2 ecosystem.json config example
{
"apps": [
{
/* General */
"name": "my-api", /* (string) application name (default to script filename without extension) */
"script": "index.js", /* (string) script path relative to pm2 start */
"cwd": "/var/www/", /* (string) the directory from which your app will be launched */
"args": "-a 13 -b 12", /* (string) string containing all arguments passed via CLI to script */
"interpreter": "/usr/bin/python", /* (string) interpreter absolute path (default to node) */
"interpreter_args": "--harmony", /* (string) option to pass to the interpreter */
@zparnold
zparnold / one_liner.sh
Last active June 25, 2024 07:12
A simply script to delete all failed pods from Kubernetes
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod