Skip to content

Instantly share code, notes, and snippets.

View vikpe's full-sized avatar
🚀

Viktor Persson vikpe

🚀
View GitHub Profile
@vikpe
vikpe / host_to_ip.rs
Created April 25, 2024 18:17
Convert host to IP address in Rust
use anyhow::{anyhow as e, Result};
pub async fn host_to_ip(host: &str) -> Result<String> {
match tokio::net::lookup_host(host).await {
Ok(mut ips) => {
if let Some(ip) = ips.next() {
Ok(ip.to_string())
} else {
Err(e!("No IP address found for {}", host))
}
@vikpe
vikpe / selfsigned_key_cert.sh
Created June 11, 2022 13:48
Generate a selfsigned key and cert
openssl genrsa -out server.key 2048
openssl ecparam -genkey -name secp384r1 -out server.key
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
@vikpe
vikpe / ubuntu_varmilo_va87m.md
Created April 13, 2022 09:04
Ubuntu: Fix f keys on Varmilo VA87M
echo 2 >> /sys/module/hid_apple/parameters/fnmode
@vikpe
vikpe / fix_authenticity_of_github_problem.md
Last active May 2, 2024 16:22
FIX: The authenticity of host github.com can't be established.

Error

The authenticity of host 'github.com (140.82.113.4)' can't be established.

Fix

ssh-keyscan github.com >> ~/.ssh/known_hosts
@vikpe
vikpe / the_zen_of_python.md
Last active February 17, 2020 09:43
The Zen of Python

The Zen of Python

https://www.python.org/dev/peps/pep-0020/

  • Beautiful is better than ugly.
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Flat is better than nested.
  • Sparse is better than dense.
  • Readability counts.
@vikpe
vikpe / open_terminals.sh
Last active May 28, 2018 10:15
Script to open multiple terminals in CentOS
#!/bin/bash
# sample config (4x2 grid on a 3840x2160 screen)
screen_cols=424
screen_rows=116
screen_width=3840
screen_height=2160
grid_col_count=4
grid_row_count=2
@vikpe
vikpe / css_responsive_border.css
Last active May 3, 2021 14:22
CSS responsive border using box-shadow to simulate the same behavior as "border-collapse: collapse"
.responsive-border {
box-shadow: 1px 0 0 0 black,
0 1px 0 0 black,
1px 1px 0 0 black,
1px 0 0 0 black inset,
0 1px 0 0 black inset;
}
@vikpe
vikpe / ssl_upgrades_rubygems_windows_workaround.md
Last active January 6, 2018 20:34
Rubygems SSL certificate error fix for Windows

Fix for rubygems SSL certificate error on Windows

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
  1. Download R1 GlobalSign Root Certificate: https://secure.globalsign.net/cacert/Root-R1.crt
  2. Save it somewhere local, so you can easily access it from a command prompt.
  3. Convert to a PEM file. openssl x509 -in Root-R1.crt -out GlobalSignRootR1.pem -outform PEM -inform DEF
  4. Copy the new GlobalSignRootR1.pem file that it creates into: D:\Ruby23-x64\lib\ruby\2.3.0\rubygems\ssl_certs\ <-- this path will obviously be different depending on where you've got Ruby installed!