Skip to content

Instantly share code, notes, and snippets.

View ansrivas's full-sized avatar

Ankur Srivastava ansrivas

View GitHub Profile
use std::{error::Error, fs::File, io::Write, path::Path};
use rsa::{
pkcs8::{EncodePrivateKey, EncodePublicKey, LineEnding},
RsaPrivateKey, RsaPublicKey,
};
use tracing_subscriber::EnvFilter;
/// Write to file if it doesn't exist.
fn write_to_file(path: &str, data: &str) -> Result<(), Box<dyn Error>> {
@ansrivas
ansrivas / github extensions
Created November 22, 2023 12:21
github extensions
https://github.com/homerchen19/github-file-icons
https://github.com/refined-github/refined-github
@ansrivas
ansrivas / uci-guest-wifi.sh
Created July 14, 2023 12:20 — forked from tongpu/uci-guest-wifi.sh
uci script for OpenWRT guest WiFi configuration
#!/bin/sh
uci batch << EOF
add network switch_vlan
set network.@switch_vlan[-1].device='switch0'
set network.@switch_vlan[-1].ports='1t 5t'
set network.@switch_vlan[-1].vlan='2'
set network.guest='interface'
set network.guest.type='bridge'
sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
docker run -d -p 27000-27015:27000-27015/udp -p 6003:6003/udp -p 7002:7002/udp cm2network/steamcmd
# login to container
@ansrivas
ansrivas / fix_touchpad_freeze.md
Last active July 31, 2020 21:43
Fedora 32 touchpad freeze fix
Keypad freeze - fedora 32
sudo rmmod i2c_hid
sudo modprobe i2c_hid
http://erikimh.com/touchpad-stops-working-after-sleep-resume-fedora-26-on-dell-xps/
@ansrivas
ansrivas / rust
Created April 20, 2020 23:10
Muslc compilation
docker run -v "cargo-cache:$HOME/.cargo" -v "$PWD:/volume" --rm -it clux/muslrust:1.44.0-nightly cargo build --bin wormhole_server --release
@ansrivas
ansrivas / implementation.rs
Created January 28, 2020 21:30
Rust tokio-postgres example custom ToSql and FromSql implementation
use postgres_types::{Type, ToSql, FromSql, IsNull, to_sql_checked};
use bytes::BytesMut;
use std::error::Error;
#[derive(Debug)]
struct RawValue<'a> {
type_: Type,
raw: Option<&'a [u8]>,
}
@ansrivas
ansrivas / generate-ssh-key.sh
Created January 16, 2020 08:32 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@ansrivas
ansrivas / update-keymapping.md
Last active August 4, 2020 23:20
update key mapping

use xenv to capture the keys which you want to replace

  • Get original key mapping using xmodmap -pke > ~/keymaptable
$ cat ~/.Xmodmap
! -*- coding: utf-8 -*-
! swapped 49 with 94
@ansrivas
ansrivas / nginx.conf
Created July 21, 2019 15:36 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048