Skip to content

Instantly share code, notes, and snippets.

View trohit's full-sized avatar
🎯
Focusing

Rohit trohit

🎯
Focusing
  • Bangalore
View GitHub Profile
@trohit
trohit / gist:adbc5284cd65054d3f20b429eb9ba5ef
Last active July 15, 2023 14:41
netstat without netstat
https://staaldraad.github.io/2017/12/20/netstat-without-netstat/
https://unix.stackexchange.com/questions/131101/without-using-network-command-lines-in-linux-how-to-know-list-of-open-ports-and
# enter as root within docker
dr exec -it -u root:root lab bash
grep -v "grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){
ret = 0
n = length(str)
@trohit
trohit / index.html
Created July 8, 2023 09:41
Horizontal Menu Navigation bar
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<nav>
<ul class="menu">
<li><a href="#">Home</a></li>
@trohit
trohit / Dockerfile
Last active July 6, 2023 02:35
Base Dockerfile for FastAPI Projects
ARG registry=library
ARG base=ubuntu
ARG version=20.04
FROM $registry/$base:$version
RUN apt-get update && apt update -y && apt-get install -y\
python3\
wget\
python3-pip\
curl\
@trohit
trohit / main.py
Created July 6, 2023 02:30
FastAPI + serve inline image
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# https://stackoverflow.com/questions/21531061/image-url-downloads-the-image-instead-of-displaying-it
from fastapi import FastAPI
from starlette.responses import FileResponse
app = FastAPI()
@app.get("/image")
async def get_image():
@trohit
trohit / main.py
Created July 5, 2023 11:03
HTTPS + FastAPI
#!/usr/bin/env python3.7
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
async def home():
return {"msg":"hi"}
@trohit
trohit / README
Created June 27, 2023 17:06
upload a file using fastapi and jinja templates
https://stackoverflow.com/questions/73263202/how-to-display-uploaded-image-in-html-page-using-fastapi-jinja2
display.html
------------
<html>
<head>
<title>Display Uploaded Image</title>
</head>
<body>
<h1>My Image</h1>
<a href="/">Upload another image</a>
@trohit
trohit / get_mfdeltas.py
Created February 10, 2020 04:59
get_mfdeltas.py
#!/usr/bin/python3
import requests
import urllib
import code
import os
from bs4 import BeautifulSoup
import pdb
import sys
url = 'https://www.mutualfundindia.com/MF/Portfolio/Details?id=32144'
is_debug_mode = False
https://www.digitalocean.com/community/tutorials/how-to-install-go-1-7-on-centos-7
# cheat sheet
https://github.com/wsargent/docker-cheat-sheet
#cmds
docker --version
docker info
docker images
docker ps
docker system prune -a
$ cat main
#!/bin/bash
rm -v /tmp/eject
i=0
while true
do
if [ -f /tmp/eject ]
then
exit 0
fi