Skip to content

Instantly share code, notes, and snippets.

Avatar
😸
use code::latest ;

GAURAV gauravssnl

😸
use code::latest ;
View GitHub Profile
@gauravssnl
gauravssnl / ray.cc
Created Sep 28, 2022 — forked from zserge/ray.cc
Minimal ray tracer for leaning purposes
View ray.cc
#include <array>
#include <cmath>
#include <fstream>
#include <iostream>
#include <vector>
struct Vec {
float x, y, z;
Vec(float vx, float vy, float vz) : x(vx), y(vy), z(vz) {}
Vec operator+(Vec vec) { return {x + vec.x, y + vec.y, z + vec.z}; }
@gauravssnl
gauravssnl / AwesomeCourses.md
Created Sep 14, 2022 — forked from teocci/AwesomeCourses.md
List of awesome university courses for learning Computer Science!
View AwesomeCourses.md

Awesome Courses Awesome

Introduction

There is a lot of hidden treasure lying within university pages scattered across the internet. This list is an attempt to bring to light those awesome courses which make their high-quality material i.e. assignments, lectures, notes, readings & examinations available online for free.

Table of Contents

View 🎵 My Spotify Top Tracks
Buy Dirt Jordan Davis & Lu
Cruel Summer Taylor Swift
Gorgeous Taylor Swift
Death By A Thousand Cut Taylor Swift
Sixteen Thomas Rhett
invisible string Taylor Swift
Nothing New (feat. Phoe Taylor Swift & Ph
All You Had To Do Was S Taylor Swift
Next To You New West
It'll Be Okay Shawn Mendes
@gauravssnl
gauravssnl / main.rs
Created Sep 1, 2022
HTTP/HTTPS TCP Server with peek HTTPS data support (not plaintext )
View main.rs
use std::{collections::HashMap, io::BufRead};
use futures::future::poll_fn;
use tokio::{
io::{self, AsyncReadExt, AsyncWriteExt, Interest},
net::{TcpListener, TcpStream},
};
const HOST: &'static str = "Host";
View infinityc.rs
#[macro_export]
macro_rules! select {
// Done normalizing
(@ { $($t:tt)* }) => {
$crate::select_imp!( $($t)* )
};
(@ { $($t:tt)* } $b:pat = $f:expr => $h:block $($r:tt)* ) => {
$crate:select!(@{ $($t)* $b = $f => $h, } $($r)*)
};
@gauravssnl
gauravssnl / std_tcp_stream_read.rs
Created Aug 31, 2022
Read standard & tokio TCPStream working examples
View std_tcp_stream_read.rs
// Read the stream data and return stream data & its length.
fn read_stream(stream: &mut TcpStream) -> (Vec<u8>, usize) {
let buffer_size = 512;
let mut request_buffer = vec![];
// let us loop & try to read the whole request data
let mut request_len = 0usize;
loop {
let mut buffer = vec![0; buffer_size];
// println!("Reading stream data");
match stream.read(&mut buffer) {
@gauravssnl
gauravssnl / main.rs
Created Aug 31, 2022
TCP Proxy variant 2 with HTTPS support
View main.rs
use std::{collections::HashMap, fmt::format, io::BufRead, ops::Index};
use tokio::{
io::{self, AsyncReadExt, AsyncWriteExt, Interest},
net::{TcpListener, TcpStream},
};
const HOST: &'static str = "Host";
#[tokio::main]
@gauravssnl
gauravssnl / Cargo.toml
Last active Aug 30, 2022
Proxy server in progress
View Cargo.toml
[package]
name = "tokio-server"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1.20.0", features = ["full"] }
tokio-stream = "0.1.9"
View tests.kdl
// Experimental sketches of specifying abi-checker tests with kdl.
// See: https://github.com/Gankra/abi-checker
//
// Basically we generate source code for different languages (c, rust, ...)
// from these abstract type/function definitions and then have them call eachother
// and check that the values didn't get corrupted along the way.
// Custom type definitions we want to pass across the ABI/convention of interest.
//
@gauravssnl
gauravssnl / lala.py
Created Aug 25, 2022 — forked from dabeaz/lala.py
Some lambdas
View lala.py
from functools import reduce
run = lambda s: reduce(lambda *_:..., iter(lambda s=[s]:
(_:=s.pop()(),s.append(_))[0], None))
const = lambda v,c : lambda: c(v)
add = lambda x,y,c : lambda: c(x+y)
mul = lambda x,y,c : lambda: c(x*y)
gt = lambda x,y,c : lambda: c(x>y)
display = lambda v,c : lambda: (print(v), c)[1]
cbranch = lambda t,c,a : (a,c)[bool(t)]