Skip to content

Instantly share code, notes, and snippets.

View harryhanYuhao's full-sized avatar
🎯
Focusing

Harry Han harryhanYuhao

🎯
Focusing
View GitHub Profile
@harryhanYuhao
harryhanYuhao / Microsoft.PowerShell_profile.ps1
Created November 6, 2024 13:21
windows powershell profile
# $PROFILE
# shall be named as $PROFILE
# check with echo $profile
New-Alias v nvim
New-Alias c clear
function pyvenv {
if (Test-Path .venv) {
Write-Host "Activating virtual environment"
@harryhanYuhao
harryhanYuhao / gitconfig
Created November 6, 2024 12:53
git aliases
[alias]
ps = push
pl = pull
st = status
ci = commit
co = checkout
br = branch
lg1 = "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all"
lg2 = "log --graph --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ai)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all"
lg = lg1
# Build Structure of this project
cmake_minimum_required(VERSION 3.10)
project(algorithm_cpp)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wunused-variable -Wuninitialized -Wsign-compare -Wfloat-equal -Wformat=2 -Wmissing-include-dirs -Wredundant-decls -Wreturn-type -Wswitch -Wswitch-enum -Wunused-parameter -Wunused-function -Wmissing-noreturn -Wnull-dereference -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wdouble-promotion -Wformat-overflow=2 -Wformat-truncation=2 -Wstack-protector -Wstrict-overflow=5 -Wvla -Wvolatile-register-var")
add_library(util SHARED util.cc)
use std::sync::{Arc, Mutex};
// dummy struct for simplicity
struct LinkedList {
next: Option<Arc<Mutex<LinkedList>>>,
val: u32,
}
fn main() {
let vec_int: Vec<u32> = vec![1, 2, 3, 4, 5];
// [dependencies]
// actix-web = "4"
// serde = "1.0.202"
// serde_derive = "1.0.202"
use actix_web::{get, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
use serde_derive::Deserialize;
#[derive(Deserialize)]
struct Info {
// cargo.toml
// [dependencies]
// tokio = { version = "1", features = ["full"] }
// sqlx = { version = "0.7", features = ["runtime-tokio", "postgres"] }
use sqlx::postgres::PgPoolOptions;
use sqlx::{Column, Executor, Row, TypeInfo, ValueRef};
struct Data {
use std::fmt;
/// representing each term of the polynomial
struct Nomial {
coefficient: f64,
power: f64,
}
impl Nomial {
fn new(coefficient: f64, power: f64) -> Self {
@harryhanYuhao
harryhanYuhao / showip.c
Created March 31, 2024 15:02
Get Ip address with syscalls
/*
** showip.c -- show IP addresses for a host given on the command line
** showip google.com
** Credit: Beej's Guide to Network Programming
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
// cargo add lettre
use lettre::address::Address;
use lettre::message::header::ContentType;
use lettre::message::Mailbox;
use lettre::transport::smtp::authentication::Credentials;
use lettre::{Message, SmtpTransport, Transport};
struct EmailInfo {
credential_username: String,
credential_password: String,
@harryhanYuhao
harryhanYuhao / execbash.go
Created February 25, 2024 13:33
go execBash
package execBash
import (
"bytes"
"os/exec"
)
func Execute(command string) (string, string, error) {
const ShellToUse = "bash"
var stdout bytes.Buffer