Skip to content

Instantly share code, notes, and snippets.

View gauravssnl's full-sized avatar
😸
use code::latest ;

GAURAV gauravssnl

😸
use code::latest ;
View GitHub Profile
@gauravssnl
gauravssnl / main.rs
Created January 3, 2023 07:13 — forked from carstein/main.rs
Example code in Rust using fork and ptrace
use nix::sys::ptrace;
use nix::sys::signal::Signal;
use nix::sys::wait::{WaitStatus, wait};
use nix::unistd::{fork, ForkResult, Pid};
use std::collections::HashMap;
use std::ffi::c_void;
use std::os::unix::process::CommandExt;
use std::process::{Command, exit};
@gauravssnl
gauravssnl / unblock-domain.md
Created January 1, 2023 17:37 — forked from grovesNL/unblock-domain.md
Unblock domains from security filters

What is this?

When you register a new domain and start hosting content there, people might not be able to view it if they're behind some kind of security software or hardware that filters by domain (e.g. web/content/DNS filters). This is because the domain is new and hasn't been categorized by the security filter, and filters commonly don't allow traffic to uncategorized domains.

Usually people can contact their security provider to request the domain to be unblocked, but:

  • this process can take a few days or longer
  • sometimes this has to be handled by IT internally and might not be escalated to the provider
    • because of this, sometimes the domain will just be unblocked for a set of people (e.g. everyone at a company) and other companies have to repeat this
  • depending on how the filtering is implemented (e.g. how requests/responses are intercepted), websites might just appear broken instead of getting an explicit message about the website being blocked
  • usually this approach is reactionary, because
public static void main(String[] argv) throws InterruptedException {
Executors.newVirtualThreadPerTaskExecutor().
execute(() -> {
System.out.print("StringList: " + stringList);
});
stringList = List.of("ZZ", "XX", "LL", "DDD");
}
@gauravssnl
gauravssnl / zig_type_system.md
Created December 29, 2022 11:33 — forked from lobre/zig_type_system.md
Zig type system illustrated using ascii diagrams

Zig Type System

Zig aims to be a simple language. It is not easy to define what simple exactly means, but zig is also a low-level programming language that aims for c-compatibility. To reach this goal, it needs good semantics in its type system so that developers have a complete toolbox to manipulate data.

So types in zig are composable, but this can become rapidly overwhelming. See those examples. Are you able to understand them at a glance, as soon as you read them?

*const ?u8
?*const u8
*const [2]u8
@gauravssnl
gauravssnl / Quirks of C.md
Created December 29, 2022 11:09 — forked from fay59/Quirks of C.md
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
@gauravssnl
gauravssnl / variadic_closures.rs
Created December 29, 2022 09:28 — forked from irh/variadic_closures.rs
An example of implementing a method that accepts closures with different arguments.
// An example of implementing a method that accepts closures with different input arguments.
// The trick to avoid Rust complaining about conflicting implementations is to specify
// the arguments for each specialization in a separate type parameter.
// See https://geo-ant.github.io/blog/2021/rust-traits-and-variadic-functions/
fn main() {
let mut foo = Foo::default();
foo.add_fn(|| 0);
foo.add_fn(|a| a);
@gauravssnl
gauravssnl / unixToolbox.md
Created December 27, 2022 15:04 — forked from tokhi/unixToolbox.md
Collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users.

#Unix Toolbox

This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations, however the reader is supposed to know what s/he is doing.

##Unix Toolbox revision 14.4

The latest version of this document can be found at http://cb.vu/unixtoolbox.xhtml. Replace .xhtml on the link with .pdf for the PDF version and with .book.pdf for the booklet version. On a duplex printer the booklet will create a small book ready to bind. This XHTML page can be converted into a nice PDF document with a CSS3 compliant application (see the script example). See also the about page.
Error reports and comments are m
@gauravssnl
gauravssnl / golang-tls.md
Created December 24, 2022 16:46 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@gauravssnl
gauravssnl / ParkingLot.zig
Created December 15, 2022 09:16 — forked from kprotty/ParkingLot.zig
Small & Fast synchronization primitives for Zig
pub fn ParkingLot(comptime Config: type) type {
return struct {
pub const Lock: type = Config.Lock;
pub const Event: type = Config.Event;
pub const nanotime: fn() u64 = switch (@hasDecl(Config, "nanotime")) {
true => Config.nanotime,
@gauravssnl
gauravssnl / Hash.md
Created December 6, 2022 15:52 — forked from cpq/Hash.md
What is a hash and how does it work

What is a hash and how does it work

Let us start from a practical example. Imagine we are writing a traffic monitoring application. The purpose of application would be to calculate a number of bytes sent by each IP address. To do that, let create a structure that does that accounting:

struct ipstat {

uint32_t ip; /* Source IP address */