Skip to content

Instantly share code, notes, and snippets.

@apla
apla / ssh-proxycommand-unusual.md
Last active January 10, 2024 17:57
SSH ProxyCommand unusual use cases

SSH ProxyCommand unusual use cases

Last years, with modern IaC tools, ssh command and protocol feel less important. More tasks are done by crafting disposable software stacks in docker images, and by setting centralised observability solutions. And ssh acts as a «last resort» manual tool.

But software is still running on the servers, and we need access to those servers sometimes. Additionally, physical resource configuration still needs to be managed, and ssh is a standard way to do this.

Using ssh is easy. Public key authentication imposes some additional learning. After you'll get used to it, ssh becomes some transparent routine.

ssh allows you to customise configuration with a set of Host and Match rules in the config file. When the host alias matches one of those rules, the following configuration options apply to the connection. Some ssh configuration options can be used with percent interpolated variables, such as %h for user-requested host alias.

@apla
apla / GitHub-api.js
Created November 9, 2023 19:27
GitHub releases
const accessToken = 'YOUR_GITHUB_ACCESS_TOKEN';
const repoOwner = 'REPO_OWNER';
const repoName = 'REPO_NAME';
const productionTag = 'production/<number>';
const targetBranch = 'development';
async function findRecentReleaseCommit(branch) {
const accessToken = 'YOUR_GITHUB_ACCESS_TOKEN'; // Replace with your GitHub access token
const url = `https://api.github.com/repos/${repoOwner}/${repoName}/commits?sha=${branch}`;
@apla
apla / dns-check.js
Created November 6, 2023 19:45
dns-check.js
const AWS = require('aws-sdk');
const dns = require('dns');
const fs = require('fs');
// Set your AWS credentials and Region
AWS.config.update({
accessKeyId: 'YOUR_ACCESS_KEY',
secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
region: 'us-east-1', // Change to your desired AWS region
});
@apla
apla / beeline,smartbox-turbo-plus.sh
Created October 25, 2023 18:11
Beeline Smartbox Turbo+ OEM settings for OpenWrt firmware selector
#!/bin/sh
. /lib/functions.sh
. /lib/functions/system.sh
get_model_name () {
cat /proc/device-tree/compatible | tr -s '\000' '\n' | head -n 1
}
get_oem_data_parser () {
@apla
apla / convert-jscad-v1.js
Last active March 18, 2024 15:13
WIP Convert JSCAD V1 => V2
const fs = require('fs').promises;
const { parse } = require('acorn');
const acornWalk = require('acorn-walk');
// Important limitations:
// Variables in attributes cannot be processed automatically, converter will throw in that case
// Whitespace and source comments lost sometimes, especially in first argument
// Constructs like x.difference(y), z.union(a, b, c) probably not supported - need parameter reordering
// If you see it not works and want to add support for that, modify `cluster.chunks.reduce` in `processCluster`
@apla
apla / proxy.pac
Created July 10, 2021 20:36
proxy
function FindProxyForURL(url, host) {
if (
dnsDomainIs(host, ".rutracker.org")
|| dnsDomainIs(host, ".lostfilm.tv")
) {
return "PROXY 10.10.10.200:18080; DIRECT";
} else {
return "DIRECT";
}
}
@apla
apla / README.md
Last active March 21, 2020 20:42
Aliexpress switch to global

Switching from russian to english version for aliexpress

Open Console from Developer tools on *.aliexpress.com, then enter

document.cookie = document.cookie.split ('; ').filter (v => v.match (/^aep_usuc_f/))[0].replace ('site=rus', 'site=glo').replace ('b_locale=ru_RU', 'b_locale=en_US') + '; domain=.aliexpress.com';
document.cookie = document.cookie.split ('; ').filter (v => v.match (/^intl_locale/))[0].replace ('ru_RU', 'en_US') + '; domain=.aliexpress.com';
@apla
apla / 04_factory_defaults.sh
Last active March 16, 2020 19:34
OpenWrt preconfigured wlan
#!/bin/sh
. /lib/functions.sh
. /lib/functions/system.sh
get_board_name () {
cat /proc/device-tree/compatible | tr -s '\000' '\n' | head -n 1
}
mtd_get_cstring () {
@apla
apla / guest.md
Last active November 8, 2019 04:23
luci segregated lans
  1. Select menu item Network > Switch and click Add button under VLAN ID section
  2. For the new VLAN, make sure the CPU is tagged, then select untagged for the LAN port(s) you are want to use this new VLAN. Make sure that port is off for all other VLANs. Click Save & Apply
  3. In the Network > Interfaces click Add new interface button (under the interface overview section)
  4. Name the new interface (Guest), select the new VLAN (likely something like eth0.3); the rest of the defaults are okay. Click Submit.
  5. Set your desired IPv4 address (for the router on this VLAN), net mask, and gateway, and any other stuff here you want. Click Save.
  6. Click Setup DHCP Server button. Defaults here are fine, but you can change them if you want. Click Save.
  7. Select the Firewall Settings tab for the interface. The radio button will default to the unspecified -or- create box. Name your firewall zone (guest). Click Save & Apply.
  8. Network > Firewall > Zones section,
@apla
apla / avr-uart-calc.markdown
Created October 24, 2019 07:12
avr-uart-calc