Skip to content

Instantly share code, notes, and snippets.

call plug#begin(stdpath("data") . '/plugged')
Plug 'catppuccin/nvim', { 'as': 'catppuccin' }
Plug 'styled-components/vim-styled-components'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'folke/trouble.nvim'
Plug 'mengelbrecht/lightline-bufferline'
Plug 'preservim/nerdcommenter'
"Plug 'jiangmiao/auto-pairs'
Plug 'simrat39/rust-tools.nvim'
Plug 'luochen1990/rainbow'
@RGGH
RGGH / sdb_4.rs
Created March 16, 2024 16:38
Learning SurrealDB + Rust
#![allow(unused)]
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use surrealdb::dbs::Response;
use surrealdb::dbs::Status;
use surrealdb::err::Error;
use surrealdb::opt::PatchOp;
use surrealdb::sql::{Thing, Value};
#[derive(Debug, Deserialize, Serialize)]
@RGGH
RGGH / surreal_rust_function.rs
Created March 12, 2024 16:46
surreal_rust_function
use std::env;
use serde::Serialize;
use surrealdb::engine::remote::ws::Ws;
use surrealdb::opt::auth::Root;
use surrealdb::Surreal;
#[derive(Debug, Serialize)]
struct Name<'a> {
first: &'a str,
last: &'a str,
@RGGH
RGGH / rust_example.rs
Created March 7, 2024 10:21
rust_example
use serde::{Deserialize, Serialize};
use surrealdb::engine::remote::ws::Ws;
use surrealdb::opt::auth::Root;
use surrealdb::sql::Thing;
use surrealdb::Surreal;
#[derive(Debug, Serialize)]
struct Name<'a> {
first: &'a str,
last: &'a str,
@RGGH
RGGH / hash_check.py
Last active March 3, 2024 20:08
hash checker for Bitcoin
#!/usr/bin/env python3
''' python3.10 hash_check.py -f inp.json '''
from binascii import unhexlify
from hashlib import sha256
import json
import sys
import urllib.request
# Convert into little endian format
@RGGH
RGGH / proof_of_work_checker.py
Created March 2, 2024 13:05
proof-of-work-checker
import hashlib
DIFFICULTY = 3 # Number of leading zeros required
def meets_difficulty(hash_string):
"""Checks if the hash string starts with the required number of zeros."""
return hash_string.startswith("0" * DIFFICULTY)
def main():
"""Hashes "Hello, World!" with varying nonces to find a valid hash."""
@RGGH
RGGH / arc_1.rs
Created February 14, 2024 19:50
arc_mutex
// cargo add colored !
use std::sync::{Arc, Mutex};
use std::thread;
use colored::Colorize;
fn main() {
// Create a shared counter wrapped in an Arc and Mutex
let counter = Arc::new(Mutex::new(1));
// Create a vector to hold the thread handles
@RGGH
RGGH / init-vim.txt
Last active March 2, 2024 12:09
init vim
call plug#begin(stdpath("data") . '/plugged')
Plug 'catppuccin/nvim', { 'as': 'catppuccin' }
Plug 'styled-components/vim-styled-components'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'folke/trouble.nvim'
Plug 'mengelbrecht/lightline-bufferline'
Plug 'preservim/nerdcommenter'
"Plug 'jiangmiao/auto-pairs'
Plug 'simrat39/rust-tools.nvim'
Plug 'luochen1990/rainbow'
@RGGH
RGGH / struct_nostr.rs
Created December 28, 2023 21:38
Struct for Nostr in Rust
#![allow(unused)]
use chrono::Utc;
use dotenv::dotenv;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::Write;
@RGGH
RGGH / digital_sig.rs
Last active December 8, 2023 19:49
digital_sig.rs
/*
[dependencies]
k256 = "0.13.2"
rand = "0.8.5"
*/
#![allow(unused)]
use k256::ecdsa::{SigningKey, VerifyingKey};
use k256::ecdsa::signature::{Signer, Verifier};
use rand::rngs::OsRng;