There is a variable $RANDOM than you can read in bash or zsh to get a random number beteen 0 and 32767. Here in zsh on my (old) mac:
% echo $RANDOM
13757
% echo $RANDOM
16896| // ==UserScript== | |
| // @name Fix YouTube's Alt-Tab Pause/Play Issue | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.4 | |
| // @description Fix YouTube's Alt-Tab Pause/Play Issue | |
| // @author HPZ07 | |
| // @match https://www.youtube.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
| // @grant none | |
| // ==/UserScript== |
| // ==UserScript== | |
| // @name Disable YouTube spacebar scrolling | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.2 | |
| // @description Disables spacebar scrolling and forces it to pause the video instead | |
| // @author HPZ07 | |
| // @match https://www.youtube.com/* | |
| // @grant none | |
| // ==/UserScript== |
This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.
| Description | Syntax |
|---|---|
| Get the length of a string | ${#VARNAME} |
| Get a single character | ${VARNAME[index]} |
| #include <X11/Xlib.h> | |
| #include <X11/Xutil.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| int main(void) { | |
| XEvent e; | |
| Display *d = XOpenDisplay(NULL); |
| // Fixing some of the errors in the: | |
| // https://gist.github.com/PumpkinSeed/b4993c6ad20ea90e3da8c991a90a91e1 | |
| // | |
| // 1. It was only able to extract database information, based upon a Struct. | |
| // The code now can deal with a struct or a slice with structs. | |
| // | |
| // 2. The code relied on the json tag in the struct. | |
| // You need to match the data with database fields, not the output fields. | |
| // This will match up more 1 to 1 as you are in controle of your Database naming and selecting of that data. | |
| // If a client expect different named exported json fields, ... |
Note: The code links are to CPython 3.8.5, the most recent release when this was written.
I was recently asked about a performance optimization in CPython around using += and + for string objects.
As some people may already know, if you use += or + a string, it can sometimes be just as fast as ''.join.
The question was to explain when that optimization couldn't be performed.
We will be going through the following example scenarios:
| \033[38;2;23;147;209m ▄ | |
| ▟█▙ | |
| ▟███▙ | |
| ▟█████▙ | |
| ▟███████▙ | |
| ▂▔▀▜██████▙ | |
| ▟██▅▂▝▜█████▙ | |
| ▟█████████████▙ | |
| ▟███████████████▙ | |
| ▟█████████████████▙ |
| # Remove current tab from tabbed | |
| super + mod1 + t; r | |
| tabc.sh $(bspc query -N -n focused) remove | |
| # At given direction: join two windows into a new tabbed or add window to an existing tabbed | |
| super + mod1 + t; {Left,Down,Up,Right} | |
| tabc.sh $(bspc query -N -n {west,south,north,east}) add $(bspc query -N -n focused) |