Skip to content

Instantly share code, notes, and snippets.

View webgtx's full-sized avatar
😃
soft wrap users, what is it like to watch a tennis match in a fullscreen editor?

Alex Zolotarov webgtx

😃
soft wrap users, what is it like to watch a tennis match in a fullscreen editor?
View GitHub Profile
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <time.h>
int main() {
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
printf("lines: %i\ncolumns: %i\n", w.ws_row, w.ws_col);
char props[] = "/#0";
// aHR0cHM6Ly9naXRodWIuY29tL3dlYmd0eAo=
#include <stdbool.h>
#include <stdio.h>
void lnrd(char * str) {
int idx = 0;
while (true) {
char ch = getchar();
if (ch == '\n')
break;
@webgtx
webgtx / gtktheme4flatpak.md
Created February 25, 2023 11:03
How to setup GTK theme for all flatpak apps

How to setup GTK theme for all flatpak apps

#!/bin/bash
cp -r /usr/share/themes/* .local/share/themes
sudo flatpak override --filesystem=$HOME/.local/share/themes
sudo flatpak override --env=GTK_THEME=Adwaita-dark
@webgtx
webgtx / main.md
Last active February 25, 2023 11:49
is it ok to run podman in the toolbox?

By default, the toolbox command works in toolbox container and podman does not.

However, if you want to use podman from within a toolbox container, you can use flatpak-spawn --host to run a command from outside the toolbox from within the toolbox.

If you alias podman to flatpak-spawn --host podman inside your container, then it’ll run your system’s podman command from within the container.

This is mainly useful if you have a terminal set up to launch your dev environment as a toolbox container and you want to run a command outside of your container sometimes.

(For what it’s worth, some commands already seem to mostly “just work” inside a container, like toolbox and rpm-ostree.)

@webgtx
webgtx / main.md
Created March 19, 2023 20:12
Authenticate to Google Container Registry with Podman

Authenticate to Google Container Registry with Podman

the xx.gcr.io is the host name. for example http://us.gcr.io etc use this doc

gcloud auth print-access-token | podman login -u oauth2accesstoken --password-stdin XX.gcr.io
@webgtx
webgtx / main.md
Created March 29, 2023 20:11
Wordpress cheatsheat

All Content Editors

  1. Static Editor - for modules
  2. Elementor - For static texts and sections
@webgtx
webgtx / main.md
Created April 10, 2023 04:13
How to reuse the same address in python sockets?
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # enable address reuse
server.bind((HOST, PORT))
server.listen(5)
print(f"RSHELL Server is running on {HOST}:{PORT}")

By calling setsockopt() on the socket object with the SO_REUSEADDR option, you are telling the operating system to allow the reuse of the same address. This should help you avoid the Address already in use error when restarting your server.

@webgtx
webgtx / ansible.cfg
Last active May 16, 2023 21:57 — forked from wbcurry/.ansible.cfg
Config Boilerplate: ansible.cfg
# config file for ansible -- http://ansible.com/
# ==============================================
# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first
[defaults]
@webgtx
webgtx / domain_extractor.rb
Created May 26, 2023 00:25
Regex in ruby, good example
def domain_name(url)
regex = /(http|https):\/\/(?:www\.)?(?<domain_name>.*?)\./
url.match(regex)[:domain_name]
end
@webgtx
webgtx / scheme_sqlite3.rb
Created May 26, 2023 17:21
sqilte3 scheme example in ruby
require "sqlite3"
db = SQLite3::Database.new("database.db")
db.execute(<<-SQL)
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
name TXT,
age INTEGER
);
SQL