Skip to content

Instantly share code, notes, and snippets.

@steelywing
steelywing / EnableSSH.js
Created January 31, 2021 05:51
Enable RedMi 2100 SSH access
// Work for RedMi 2100 firmware 2.0.23
// http://cdn.cnbj1.fds.api.mi-img.com/xiaoqiang/rom/rm2100/miwifi_rm2100_all_fb720_2.0.23.bin
function getSTOK() {
let match = location.href.match(/;stok=(.*?)\//);
if (!match) {
return null;
}
return match[1];
}
@zjeaton
zjeaton / _Google Analytics 4 with Hugo.md
Last active May 23, 2024 01:13
Google Analytics 4 (with Measurement ID) in Hugo

Google Analytics 4 in Hugo

Blog post with slightly more detail can be found here. If you want to just get to it, read on.

I (very) recently decided to reimplement GA in my site, and found that existing implementation in Hugo was not compatible with GA4's new Measurement ID. This is an easy way to drop your Measurement ID into your site. I'm not going to go into how to sign up for GA.

This implementation requires that you create a site parameter for analytics, create a partial, and call the partial. I tweaked the names of the parameters and files so they didn't collide with the built-in hugo code.

Place the GoogleAnalyicsID (Measurement ID) in config.toml within [params].

do
do
local _ENV = _ENV
package.preload[ "locator" ] = function( ... ) local arg = _G.arg;
local module = {}
local labels = {
book = 'book',
['bk.'] = 'book',
@lilydjwg
lilydjwg / colors.py
Last active August 12, 2024 05:35
colors.py: show all kinds of terminal colors at a glance
#!/usr/bin/python3
from functools import partial
def colors16():
for bold in [0, 1]:
for i in range(30, 38):
for j in range(40, 48):
print(f'\x1b[{bold};{i};{j}m {bold};{i};{j} |\x1b[0m', end='')
print()
on:
push:
branches:
- master
name: build_and_goto_gh_pages
jobs:
blogdown:
name: build_and_push_to_gh_pages
@karlredman
karlredman / joplin-keymap.json
Last active September 2, 2023 04:51
vim-sh keymap.json for Joplin Terminal Application (CLI)
[
{ "keys": [":"], "type": "function", "command": "enter_command_line_mode" },
{ "keys": ["q"], "type": "prompt", "command": "exit", "cursorPosition": -1 },
{ "keys": ["/"], "type": "prompt", "command": "search \"\"", "cursorPosition": -2 },
{ "keys": ["TAB","l"], "type": "function", "command": "focus_next" },
{ "keys": ["SHIFT_TAB","h"], "type": "function", "command": "focus_previous" },
{ "keys": ["UP","k"], "type": "function", "command": "move_up" },
{ "keys": ["DOWN","j"], "type": "function", "command": "move_down" },
{ "keys": ["PAGE_UP","K","u"], "type": "function", "command": "page_up" },
@Lartza
Lartza / tmux.conf
Last active August 10, 2024 07:10 — forked from anonymous/tmux.conf
vim friendly tmux configuration
#Prefix is Ctrl-a
set -g prefix C-a
bind C-a send-prefix
unbind C-b
set -sg escape-time 1
set -g base-index 1
setw -g pane-base-index 1
#Mouse works as expected
@coin8086
coin8086 / using-proxy-for-git-or-github.md
Last active August 2, 2024 02:49
Use Proxy for Git/GitHub

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocol you use. And there're two common protocols: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocol. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@Mukei
Mukei / conda_environment_rename.sh
Created November 30, 2017 07:01
How to rename a conda environment (workaround)
#One workaround is to create clone environment, and then remove original one:
#(remember about deactivating current environment with deactivate on Windows and source deactivate on macOS/Linux)
conda create --name new_name --clone old_name --offline #use --offline flag to disable the redownload of all your packages
conda remove --name old_name --all # or its alias: `conda env remove --name old_name`
#There are several drawbacks of this method:
# time consumed on copying environment's files,
# temporary double disk usage.
@HardenedArray
HardenedArray / Efficient Encrypted UEFI-Booting Arch Installation
Last active October 22, 2023 12:14
An effcient method to install Arch Linux with encrypted root and swap filesystems and boot from UEFI. Multi-OS, and VirtualBox, UEFI-booting are also supported.
# OBJECTIVE: Install Arch Linux with encrypted root and swap filesystems and boot from UEFI.
# Note this encrypted installation method, while perfectly correct and highly secure, CANNOT support encrypted /boot and
# also CANNOT be subsequently converted to support an encrypted /boot!!! A CLEAN INSTALL will be required!
# Therefore, if you want to have an encrypted /boot or will want an encrypted /boot system at some point in the future,
# please ONLY follow my encrypted /boot installation guide, which lives here: