Skip to content

Instantly share code, notes, and snippets.

View poseidon-code's full-sized avatar
🔱
Aura : 999999+

Pritam Halder poseidon-code

🔱
Aura : 999999+
View GitHub Profile
@poseidon-code
poseidon-code / Golang Cheat Sheet.md
Last active September 25, 2021 08:15
A list of links to best Golang Cheat sheets on internet,
@poseidon-code
poseidon-code / Python Cheat Sheet.md
Created September 25, 2021 08:13
A list of links to best Python Cheat sheets on internet,
@poseidon-code
poseidon-code / Core Java Cheat Sheet.md
Created September 25, 2021 08:41
A list of links to best Core Java Cheat sheets on internet,
@poseidon-code
poseidon-code / Go Query Patterns.md
Last active October 11, 2021 07:49
Query handling patterns for Go based REST server with builtin "net/http" package.
func User(w http.ResponseWriter, r *http.Request) {
    query := r.URL.Query()
    
    if r.URL.Path == "/user/" {
        switch r.Method {
        case http.MethodOptions:
        case http.MethodGet:
            if query["id"]!=nil && len(query)==1 {
                // checks "/user/?id=<some_value>", then true
@poseidon-code
poseidon-code / Typescript Cheat Sheet.md
Last active November 14, 2021 12:50
A list of links to best Typescript Cheat sheets on internet.
@poseidon-code
poseidon-code / Go Dynamic Paths.md
Last active October 22, 2021 15:30
Express like path handling method for Go. Path: "/user/:name/dashboard/stats/:range/", here "name" & "range" are params which are accessed within the "request" object of Express router handler.

Basic Idea : The function receives 'path' that will be handled by the server and the 'url' the request was sent to/from. It will split the 'path' into all the params and parse's and finds those params which has ":" at the beginning. It will also split the 'url' into all the params that were sent from server. A loop, loops over all the elements inside the splitted 'path' (here, path_list), finds the position where ":" is present in a element of path, removes the ":", creates key of with that element, and sets value of the key from the splitted 'url' (here, url_list) at the same index position. Makes a map of key-value pairs, returns it, with a boolean of whether the 'path' and 'url' are a match.

// path : the path the `url` will be mathced with
// url : the url the request was sent/received to/from server
func handlePath(path string, url string) (bool, map[string]string) {
@poseidon-code
poseidon-code / MySQL Cheat Sheet.md
Created November 14, 2021 12:55
A list of links to best MySQL Cheat sheets on internet.
@poseidon-code
poseidon-code / Python MySQL Driver Snippets.py
Created April 11, 2022 16:58
Snippets for Python and Python's MySQL driver connection.
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="sql_username",
password="sql_user_password",
database="db_name" # = "USE <database name>;"
)
cursor = db.cursor()
@poseidon-code
poseidon-code / Github Setup.md
Last active September 13, 2022 07:03
Generating SSH & GPG keys for Github in Linux.

Generating SSH keys

ssh-keygen -t ed25519 -C "email@gmail.com"

Enter a passphrase
Enter ~/.ssh/github as a save path

Enabling SSH keys

exec ssh-agent zsh
@poseidon-code
poseidon-code / Docker Cheat Sheet.md
Created September 16, 2022 16:23
A list of links to best Docker Cheat sheets on internet.