Skip to content

Instantly share code, notes, and snippets.

View dipu-bd's full-sized avatar

Sudipto Chandra dipu-bd

View GitHub Profile
@dipu-bd
dipu-bd / protobuf.py
Created February 2, 2022 07:22
Protobuf encoder and decoder test
class Protobuf:
def __init__(self, raw: bytes) -> None:
self.raw = raw
self.offset = 0
@property
def fields(self) -> dict:
if not hasattr(self, '__fields__'):
self.__fields__ = {}
while self.has_next():
@dipu-bd
dipu-bd / gfont_downloader.py
Last active July 6, 2021 15:11
Google fonts downloader script in python
#!/usr/bin/env python3
import os
import re
from requests import Session
from urllib.parse import urlparse, parse_qs, quote_plus
from argparse import ArgumentParser
src_url_matcher = re.compile(r'''url\(["']?([^"')]+)["']?\)''')
@dipu-bd
dipu-bd / powershell.ps1
Created June 2, 2021 01:55
PowerShell Config for autocompletion and persisting history
# Shows navigable menu of all options when hitting Tab
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Autocompletion for arrow keys
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
#Save Command History
$HistoryPath = 'C:\Users\Dipu\Documents\WindowsPowerShell\History'
@dipu-bd
dipu-bd / TimestampTest.java
Last active January 26, 2021 12:03
Test Timestamp and TimestampTZ data types of PostgreSQL
package com.test.time;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCallback;
import java.sql.Timestamp;
@dipu-bd
dipu-bd / build.sh
Last active December 14, 2020 17:01
Automate the deployment of a Vue CLI single page application. Related: https://gist.github.com/dipu-bd/043d1dc686ef6c95fbca8c39a2954a68
#!/bin/sh
pwd
rm -rf dist build venv
yarn
yarn build
python3 -m venv venv
@dipu-bd
dipu-bd / server.py
Last active December 14, 2020 17:02
A simple python server to serve website files from a directory. Related: https://gist.github.com/dipu-bd/1183ca6a6f9968853e17bcc7820d895d
#!/usr/bin/env python
import http.server
import os
import socketserver
import time
from argparse import ArgumentParser
start_time = time.time()
@dipu-bd
dipu-bd / OkWalletTest.java
Created October 31, 2020 12:47
OkWallet Test api
package com.infinity.kyc.api.face;
import org.springframework.util.StreamUtils;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class OkWalletTest {
public static void main(String[] args) throws Exception {
@dipu-bd
dipu-bd / Makefile
Created July 3, 2020 02:29
OS Detection in Makefile
ifeq ($(OS),Windows_NT)
CCFLAGS += -D WIN32
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
CCFLAGS += -D AMD64
else
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
CCFLAGS += -D AMD64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
CCFLAGS += -D IA32
@dipu-bd
dipu-bd / turing.json
Last active January 13, 2024 00:24
JSON schema for a Turing complete machine
{
"$schema": "http://json-schema.org/schema",
"title": "JSON schema for a turing complete machine",
"type": "object",
"definitions": {
"statement": {
"description": "",
"type": "object",
@dipu-bd
dipu-bd / urllib.dart
Last active May 2, 2020 23:52
This is a direct port of python's urllib.parse.urlparse into dart. Additionally, it splits the netloc (authority) component into user, password, host and port components.
class URL {
final String original;
String _fragment = '';
String _query = '';
String _scheme = '';
String _user = '';
String _password = '';
String _host = '';
String _port = '';
String _path = '';