Skip to content

Instantly share code, notes, and snippets.

@mfridman
mfridman / go-ssh-hostkey.go
Last active June 15, 2020 21:25
Go host key checking for non-standard port(s)
// thes below two functions are talked about in
// http://mfridman.com/2017/09/04/go-ssh-hostkey.html
func validatePort(s string) (string, error) {
// empty string defaults to port 22, ports 1-65535 valid, otherwise error
if s == "" {
// it is the caller's responsibility to pass in a valid, non-empty port
return "22", nil
}
i, _ := strconv.Atoi(s)
@braian87b
braian87b / image-builder-openwrt-lede.sh
Last active December 11, 2024 14:04
Image-Builder Procedure for OpenWRT - LEDE
# ------------------------------------------------------------------------
# Image-Builder Procedure for OpenWRT - LEDE (In this case using Debian x64 NetInstall virtual machine)
# ------------------------------------------------------------------------
su
apt-get update # Optional, make and upgrade too in case it has too many old pakackes.
apt-get install make aria2 screen ncftp -y
screen -
cd ~
@pesterhazy
pesterhazy / ripgrep-in-emacs.md
Last active July 19, 2024 16:05
Using ripgrep in Emacs using helm-ag (Spacemacs)

Why

Ripgrep is a fast search tool like grep. It's mostly a drop-in replacement for ag, also know as the Silver Searcher.

helm-ag is a fantastic package for Emacs that allows you to display search results in a buffer. You can also jump to locations of matches. Despite the name, helm-ag works with ripgrep (rg) as well as with ag.

How

@alfredkrohmer
alfredkrohmer / list-user-installed-packages.sh
Created February 11, 2017 13:39
List all user-installed packages on OpenWrt / LEDE
#!/bin/sh
FLASH_TIME=$(opkg info busybox | grep '^Installed-Time: ')
for i in $(opkg list-installed | cut -d' ' -f1)
do
if [ "$(opkg info $i | grep '^Installed-Time: ')" != "$FLASH_TIME" ]
then
echo $i
fi
@jwalanta
jwalanta / OpenWrt detect new device and send text message.md
Last active March 31, 2025 18:22
Detect new network devices connecting to OpenWrt and send text message
@lg
lg / angry_wifi.sh
Last active January 20, 2025 03:22
auto disconnects clients with a low signal strength on LEDE / OpenWRT
#!/bin/ash
#
# angry_wifi.sh
#
# auto disconnects clients with a low signal strength on LEDE / OpenWRT. great
# for clients who hold onto a lower-signal-strength accesspoint instead of
# roaming. before running, make sure to download the latest MAC addresses with:
#
# wget --no-check-certificate -O - 'https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MAC&text=apple' | cut -d, -f2 > apple_mac_addresses
#
@mpeven
mpeven / captive_portal.sh
Last active January 10, 2023 00:47
iOS captive portal
# Captive portal setup
########################################################
sudo apt-get update -qq
sudo apt-get install -qq dnsmasq vim hostapd ufw dnsutils netstat-nat conntrack nginx php5 php5-common php5-fpm
sudo mkdir /usr/share/nginx/html/portal
sudo useradd nginx
sudo chown nginx:www-data /usr/share/nginx/html/portal
sudo chmod 755 /usr/share/nginx/html/portal
########################################################
local enummt = {
__index = function(table, key)
if rawget(table.enums, key) then
return key
end
end
}
local function Enum(t)
local e = { enums = t }
(require 'cl)
(require 'ivy)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General-purpose formatting functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ivy--cands-get-details (format_spec cand_info_fns entries)
"Extract symbols from FORMAT_SPEC, and evaluate the
corresponding function found in CAND_INFO_FNS for all ENTRIES.
For example:
(setq my_format_spec '(make-upper-case