Skip to content

Instantly share code, notes, and snippets.

View sanjarcode's full-sized avatar

Sanjar Afaq sanjarcode

View GitHub Profile
@sanjarcode
sanjarcode / requests.md
Last active September 3, 2023 14:14
HTTP requests in variouslanguages/runtimes

HTTP Requests and responses in various languages

JavaScript

1. fetch API

// GET request
fetch('https://example.com/data')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error))
# instructions: place images in same directory as this file. Run the file.
from PIL import Image
import pyocr
import pyocr.builders
import os
# Print the list of png files
def get_images_list():
# Get the list of all files in the current directory
@sanjarcode
sanjarcode / .gitignore
Last active September 30, 2024 06:10
Custom JS for the browser
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@sanjarcode
sanjarcode / .megasyncignore
Created January 18, 2023 03:58
Personal cloud sync ignore file
# Context for exclusion
# 1. For excluding files, use .gitignore as hint.
# 2. Soft exclusion - Don't copy .gitignore blindly. IDE settings are still.
# .gitignore syntax - MEGAsync exclusion syntax
# 1. /dirName - dirName - directory exclusion
# 2. dir1/dir2 - */dir1/dir2 - MEGAsync is not consistent with exclusion syntax
# Tip - Delete all files to be excluded before settings the exclusion.
# Otherwise the excluded file will have a single stagnant instance in the cloud.
@sanjarcode
sanjarcode / volopay_test.py
Last active December 20, 2022 05:45
Code files
import unittest
class PlaneSeating:
def __init__(self, seat_block_column_n_row, number_of_passsengers):
self.seat_block_column_n_row = seat_block_column_n_row
self.number_of_passsengers = number_of_passsengers
# calculate number of seats of each type
@sanjarcode
sanjarcode / ec2-restart
Last active April 16, 2022 08:08
Setup domain and hosting on server
### EC2 restart
If your server is restarted, its public IPv4 address may change, in that case,
just update the `Route 53` type A record with the new address.
@sanjarcode
sanjarcode / .gitconfig
Last active July 14, 2025 16:23
Multiple Git accounts on a device, with SSH keys
# ~/.gitconfig - the global config
[user]
name = Sanjar Afaq
email = [email protected]
[includeIf "gitdir:~/volopay-work/"]
path = ~/volopay-work/.gitconfig
[core]
editor = code --wait
@sanjarcode
sanjarcode / how_to_share.md
Last active February 26, 2024 04:12
Browser hacks/tools
@sanjarcode
sanjarcode / .cursorrules
Last active November 7, 2025 10:55
Dotfiles - Linux, MacOS shell primer files - .bashrc and others
The contents of this repo are placed at ~/.dotfiles.
The idea is to quickly install/uninstall/edit dot files.
It also contains env files (with the actual values being hidden).
@sanjarcode
sanjarcode / .gitignore
Last active October 3, 2025 06:27
Computer setup - installing OS, post installation sets - Ubuntu (20.04), or macOS
.vscode