Skip to content

Instantly share code, notes, and snippets.

View aryamansharda's full-sized avatar

Aryaman Sharda aryamansharda

View GitHub Profile
@aryamansharda
aryamansharda / LZWDecoder.py
Created January 22, 2021 03:37
LZW Decoder
import sys
from sys import argv
import struct
from struct import *
def decompress():
# Default values in order to read the compressed file
compressed_data = []
next_code = 256
decompressed_data = ""
@aryamansharda
aryamansharda / typing_distance.py
Created June 11, 2021 15:51
Typing Distance Calculator
file = open('blog.txt', 'r')
characters = {
"1": 4,
"2": 4,
"3": 4,
"4": 4,
"5": 4,
"6": 5,
"7": 4,
@aryamansharda
aryamansharda / LowPolygonArt.py
Last active June 30, 2021 04:40
LowPolygonArt
import random
import numpy as np
# https://github.com/jmespadero/pyDelaunay2D
from delaunay2D import Delaunay2D
from PIL import Image
from PIL import ImageDraw
# Load an image from file path
img = Image.open('Jaipur.jpg').convert('RGBA')
@aryamansharda
aryamansharda / Log.swift
Created July 4, 2021 03:05
Logging In Swift [The Right Way]
import Foundation
enum Log {
enum LogLevel {
case info
case warning
case error
fileprivate var prefix: String {
switch self {
@aryamansharda
aryamansharda / AnalyticsManager.swift
Created February 10, 2022 07:18
AnalyticsManager
// 1
protocol AnalyticsProvider {
func sendAnalyticsEvent(named name: String, metadata: [String : Any]?)
}
// 2
import FirebaseAnalytics
struct FirebaseAnalyticsProvider: AnalyticsProvider {
func sendAnalyticsEvent(named name: String, metadata: [String : Any]?) {
Analytics.logEvent(name, parameters: metadata)
@aryamansharda
aryamansharda / NetworkLayerDemo.swift
Last active January 19, 2024 15:49
Network Layer Demo
enum HTTPMethod: String {
case delete = "DELETE"
case get = "GET"
case patch = "PATCH"
case post = "POST"
case put = "PUT"
}
enum HTTPScheme: String {
case http
@aryamansharda
aryamansharda / check-ambiguous-references.py
Created March 5, 2022 05:06
Checks staged files for ambiguous constraints
import sys
if __name__ == '__main__':
arguments = sys.argv
# The first parameter is always the call to this executable "python3 check-ambiguous-references" which we can drop
arguments.pop(0)
ambiguous_constraints_found = False
# Searches through all of the modified files looking for the introduction of ambiguous constraints
@aryamansharda
aryamansharda / Creating PDFs From WKWebView
Created February 19, 2023 20:40
Creating PDFs From WKWebView
//
// ViewController.swift
// WebKitPDFAndImageDemo
//
// Created by Aryaman Sharda on 2/18/23.
//
import UIKit
import WebKit