Skip to content

Instantly share code, notes, and snippets.

View vishal1132's full-sized avatar

Vishal Sharma vishal1132

View GitHub Profile
@vishal1132
vishal1132 / timeoutmiddleware.go
Last active August 23, 2021 15:26
Go HTTP Server with timeout middleware, which defaults a generic response on request timeout
package main
import (
"context"
"fmt"
"log"
"net"
"net/http"
"time"
)
package main
import (
"bytes"
"log"
"os"
"os/exec"
"strings"
)
@vishal1132
vishal1132 / docker-compose.yml
Created June 11, 2021 16:43
logsserver docker compose file
version: '2'
services:
logsservice:
container_name: logsserver
image: ansh09890/logsserver:latest
environment:
port: 8082
kafka: kafka
ports:
- 8082:8082

#File Magic Numbers

Magic numbers are the first bits of a file which uniquely identify the type of file. This makes programming easier because complicated file structures need not be searched in order to identify the file type.

For example, a jpeg file starts with ffd8 ffe0 0010 4a46 4946 0001 0101 0047 ......JFIF.....G ffd8 shows that it's a JPEG file, and ffe0 identify a JFIF type structure. There is an ascii encoding of "JFIF" which comes after a length code, but that is not necessary in order to identify the file. The first 4 bytes do that uniquely.

This gives an ongoing list of file-type magic numbers.

##Image Files

package main
import "fmt"
type cache struct {
maxSize int
currSize int
head *doublyLinkedList
tail *doublyLinkedList
cacheMap map[int]*doublyLinkedList
on:
issues:
types:
- opened
push:
branches:
- master
name: dev deployment
jobs:
@vishal1132
vishal1132 / docker-aliases.sh
Created October 21, 2021 13:43 — forked from jgrodziski/docker-aliases.sh
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #
@vishal1132
vishal1132 / socat-tcp-to-unix-socket.sh
Created October 27, 2021 04:10 — forked from ljjjustin/socat-tcp-to-unix-socket.sh
socat-unix-socket-to-tcp.sh
#!/bin/bash
if [ $# -ne 3 ]; then
echo "usage: $0 <unix socket file> <host> <listen port>"
exit
fi
SOCK=$1
HOST=$2
PORT=$3
db.users.aggregate([
  {
    "$lookup": {
      "as": "companyData",
      "foreignField": "_id",
      "from": "companies",
      "localField": "company_id"
    }
  },
@vishal1132
vishal1132 / clojure-beginner.md
Created January 19, 2022 03:58 — forked from yogthos/clojure-beginner.md
Clojure beginner resources

Introductory resources