Skip to content

Instantly share code, notes, and snippets.

View nik-hil's full-sized avatar
🏠
Working from home

Nikhil nik-hil

🏠
Working from home
View GitHub Profile
@nik-hil
nik-hil / img2pdf.py
Created June 28, 2024 05:05
Convert images to pdf using python.
import PyPDF2
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from PIL import Image
import argparse
def convert_images_to_pdf(image_paths, output_pdf_path):
c = canvas.Canvas(output_pdf_path, pagesize=letter)
for image_path in image_paths:
@nik-hil
nik-hil / .vimrc
Created August 24, 2023 17:31
My Vim configuration
:syntax enable
:set cursorline
:set cursorcolumn
:set number
@nik-hil
nik-hil / Original_main.go
Created February 19, 2023 07:13
Golang using interface for better testing.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
@nik-hil
nik-hil / cowin_schedule_v3.js
Created May 5, 2021 10:21 — forked from debarko/cowin_schedule_district_wise.js
Get an update on console as soon as a slot opens up in https://selfregistration.cowin.gov.in/ . Login to the website and then run this script on Console.
// This script will alert you whenever some slot opens up on the given date within the given pincodes
// Change the pincodes to your needs as per your city
// Change the dateArr to add your convinent set of dates
// For further update do checkout http://twitter.com/debarko/
// Steps to use
// 1. Update Config
// 2. Login to https://selfregistration.cowin.gov.in/
// 3. Rigt Click on the website
@nik-hil
nik-hil / fastai_on_gcp_using_terraform.tf
Created March 4, 2020 16:36
create fastai server on gcp using terraform.
provider "google" {
credentials = file("CREDENTIALS_FILE.json")
project = "famous-muse-247206"
region = "us-west1"
}
# TF-UPGRADE-TODO: Block type was not recognized, so this block and its contents were not automatically upgraded.
resource "random_id" "instance_id" {
byte_length = 8
}
@nik-hil
nik-hil / Google Colab SSH
Created July 4, 2019 04:46 — forked from yashkumaratri/Google Colab SSH
SSH into google colab
#CODE
#Generate root password
import random, string
password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))
#Download ngrok
! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
! unzip -qq -n ngrok-stable-linux-amd64.zip
#Setup sshd
@nik-hil
nik-hil / cmd.sh
Created October 27, 2018 07:49
small useful bash commands
# see gpu usage
nvidia-smi
# see gpu usage every 10 sec
watch -n 10 nvidia-smi
@nik-hil
nik-hil / alpha.py
Created October 19, 2018 09:25
plot image with alpha, with mask
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.patches import Rectangle
import pydicom
import numpy as np
import torchvision as tv
img = pydicom.dcmread('/Users/nikhil/workspace/src/rsna/dcm/00aecb01-a116-45a2-956c-08d2fa55433f.dcm').pixel_array
img = np.expand_dims(img, -1)
img_pil = tv.transforms.functional.to_pil_image(img)
@nik-hil
nik-hil / Resize_image.py
Created September 13, 2018 13:55
resize image in python from one location to another. Not a clean one
from pathlib import Path
from tqdm import tqdm
import pydicom
import numpy as np
from PIL import Image
sz=224
PATH = Path('big')
img_dir = PATH/'image'
TEST = False