Skip to content

Instantly share code, notes, and snippets.

View uroybd's full-sized avatar
🧙
Meditating on the life, the universe, and everything.

Utsob Roy uroybd

🧙
Meditating on the life, the universe, and everything.
View GitHub Profile
@uroybd
uroybd / day8_2.rs
Created December 9, 2021 03:34
A not so elegant solution of Advent of Code 2021: Day 8, Part 2
use std::collections::HashMap;
pub fn read_lines(filename: String) -> Vec<String> {
let content: Vec<String> = fs::read_to_string(filename)
.expect("Invalid File")
.split('\n')
.map(|s| s.to_string())
.collect();
return content;
}
@uroybd
uroybd / large_small.py
Created June 29, 2020 11:46
Largest and Smallest
import sys
largest_by_far = sys.float_info.min
smallest_by_far = sys.float_info.max
while True:
value = input("Enter Numbers: ")
if value == "done":
break
try:
fvalue = float(value)
@uroybd
uroybd / createGlossary.py
Created April 18, 2020 18:48
Creating Stardict from python dict.
import csv
MY_DICT = {"a": "a definition"} # assuming this is your dict
data = list(MY_DICT.items())
with open('glossary.txt', 'w') as gfile:
writer = csv.writer(gfile, delimiter="\t")
writer.writerows(data)

Keybase proof

I hereby claim:

  • I am uroybd on github.
  • I am uroybd (https://keybase.io/uroybd) on keybase.
  • I have a public key ASDAvqxhvhTXcjkzLfpaldu_T9EmLDU80ej4KEkZY2MyQAo

To claim this, I am signing this object:

@uroybd
uroybd / bengaliUnit.js
Last active February 10, 2018 13:04
Javascript Regex to get 'Units' from Bengali text. (Useful for text transforming bengali with JS)
var bengaliUnitRegex = /([অ-হড়-য়](্[অ-হড়-য়])+|[অ-হড়-য়]্|[অ-হড়-য়])[া-ৌ]*[ঁঃং]*|ৎ|[০-৯]| /g;
// You can match with str.mathc(rg) and it will yield units as array. Example:
var testText = "আদর্শলিপি";
testText.match(bengaliUnitRegex);
// > ["আ", "দ", "র্শ", "লি", "পি"]
@uroybd
uroybd / classy_case.py
Last active November 14, 2017 09:14
A 'Classy' Case for Python
class Case:
"""A Class to simulate case behavior in a more compact way.
Optionaly, default value and a conditional function can be passed.
cases and **kwargs are for flexibility since you can't have nothing
but string keys in kwargs. They both get combined in a single switch.
Return value for switches can be either a value or callable.
Stupid thingy, I know right! :D
@uroybd
uroybd / ticky_tacky.py
Last active October 7, 2016 17:41
Tic Tac Toe in python
import pandas as pd
def check_equal(lst):
if lst[0] != " ":
return lst[1:] == lst[:-1]
else:
return False
def if_win(board):
for i in range(3):
@uroybd
uroybd / scrapper.py
Created September 25, 2016 04:25
A simple Job crawler for bdjobs
import csv
from requests import post
from functools import reduce
from bs4 import BeautifulSoup
def soup_to_dict(dt):
"""Job html soup to dictionary"""
main_site = 'http://jobs.bdjobs.com/'
data_dict = {};
@uroybd
uroybd / sudokusolver.py
Last active July 24, 2016 08:18
Sudoku Solver
from copy import deepcopy
# Datastructure: [{'r': int, 'c': int, 'd': boolean, 'v': int, 'p': vecotor of int}.....]
def related(case, unit, data):
grider = [[1,2,3], [4,5,6], [7,8,9]]
for g in grider:
if unit['c'] in g:
cols = g
if unit['r'] in g:
@uroybd
uroybd / main.py
Last active July 18, 2016 14:54
URI 1914
def verdict(P1,P2,C1,C2,M,N):
if (M + N) % 2 == 0:
v = 'PAR'
else:
v = 'IMPAR'
if C1 == v:
return P1
else:
return P2