Skip to content

Instantly share code, notes, and snippets.

@slorber
slorber / generate-docs-from-js.js
Last active April 2, 2024 19:37 — forked from arinthros/generate-docs-from-js
Generate Docusaurus Docs from JSDoc
/**
* Requires jsdoc and jsdoc-to-markdown
*/
/* eslint-disable no-console */
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const { execSync } = require('child_process')
const jsdoc2md = require('jsdoc-to-markdown')
@sindresorhus
sindresorhus / esm-package.md
Last active April 26, 2024 03:53
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.

Create Windows Terminal shortcut in Windows + X context menu

Windows Terminal shortcut in WinX context menu

In Windows PowerShell do the following:

$folderPath = "$ENV:LOCALAPPDATA\Microsoft\Windows\WinX\Group3"
$adminFilePath = Join-Path $folderPath "00 - Windows Terminal.lnk"
$normalFilePath = Join-Path $folderPath "00a - Windows Terminal.lnk"
@mattmattox
mattmattox / rke_recovery.sh
Last active March 1, 2024 06:36
Recovering cluster.yml and cluster.rkestate from kubeconfig
#!/bin/bash
echo "Building cluster_recovery.yml..."
echo "Working on Nodes..."
echo 'nodes:' > cluster_recovery.yml
kubectl --kubeconfig kube_config_cluster.yml -n kube-system get configmap full-cluster-state -o json | jq -r .data.\"full-cluster-state\" | jq -r .desiredState.rkeConfig.nodes | yq r - | sed 's/^/ /' | \
sed -e 's/internalAddress/internal_address/g' | \
sed -e 's/hostnameOverride/hostname_override/g' | \
sed -e 's/sshKeyPath/ssh_key_path/g' >> cluster_recovery.yml
echo "" >> cluster_recovery.yml
@Mecanik
Mecanik / gist:d2314fbc860b9c68eac4b101127b738e
Created November 4, 2019 11:58
Install and configure PHP 7.3 ev/event PECL extension on Ubuntu Linux 18.04.3
# For phpize
apt install php7.3-dev
# Install extensions
pecl install ev
pecl install event
# Create configurations
sudo echo 'extension=ev.so' > /etc/php/7.3/mods-available/ev.ini
sudo echo 'extension=event.so' > /etc/php/7.3/mods-available/event.ini

Why to Ignore Russian Internet Laws

There is internet censorship in Russia. VPNs and internet providers are required to install into their networks Revizor, a device that checks that censored sites can't be accessed from their network. They are also required to install SORM (wiki/SORM, another wiki) to help Russian special services to analyse traffic and track users.

If you have or are going to have internet business in Russia I call you to ignore all the demands to install SORM and Revizor into your network. Also don't move personal data to Russia. If you can't avoid complying to these demands then just don't have your business in Russia at all.

Please, don't invest in Cheburnet (autonomous Russian internet that can be easily isolated and abusively censored without any collateral damage). Cheburnet is built to help the Kremlin in power usurpation.

The Reasons

#!/bin/bash
# This stupid script can convert slack json exports
# (created with https://solawivuml.slack.com/apps/A19P6G35Y-export?next_id=0)
# to rocket.chat csv imports.
# The zip file can be directelly imported into rocket.chat.
test -z $1 && echo "usage: $0 slack_export_json_file.json channel_name" && exit 1
# format users (needed for import)
cat $1 | jq '.[] | {name,real_name} | @json' | awk -F '"' '{print $5","$5"@dummy.import,"$9}' | sed 's#\\##g' | sort -n | uniq >users.csv
@jsdevtom
jsdevtom / frontend-ws-connection.ts
Last active April 17, 2024 07:35
kubernetes-ingress websockets with nodejs
export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`);
export const wsObserver = ws
.pipe(
retryWhen(errors =>
errors.pipe(
delay(1000)
)
)
);
@ruohki
ruohki / 1-rbac.yaml
Last active January 5, 2019 22:01 — forked from carloscarnero/1-rbac.yaml
Traefik on Rancher
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: traefik-ingress-controller
rules:
- apiGroups:
- ""
resources:
- services
@superseb
superseb / cluster.yml
Last active February 7, 2024 09:08
Rancher 2.x custom cluster YAML quicker node failure detection (k8s 1.13)
services:
kubelet:
extra_args:
node-status-update-frequency: 4s
kube-api:
extra_args:
default-not-ready-toleration-seconds: 30
default-unreachable-toleration-seconds: 30
kube-controller:
extra_args: