Skip to content

Instantly share code, notes, and snippets.

View mailtodanish's full-sized avatar
:octocat:
Working From Home

Mohd Ahshan Danish mailtodanish

:octocat:
Working From Home
View GitHub Profile
@mailtodanish
mailtodanish / compression.py
Created December 20, 2021 13:19
Problem Overview: String Compression
def compress(s):
compressed_string =""
length=0
ch=re.findall(r"(\w)\1*", s)
for z in ch:
m=re.search(r'{}*'.format(z), s)
length = len(m.group(0))
compressed_string ="{}{}{}".format(compressed_string,z,length)
s =s[length:]
return compressed_string.replace("1","")
@mailtodanish
mailtodanish / format_date.js
Created December 27, 2021 09:42
Format date in java script
//format date in JS
let d = new Date(2010, 7, 5);
function formatted_date(d){
let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
let mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(d);
let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);
return `${da}-${mo}-${ye}`;
}
formatted_date(d);
@mailtodanish
mailtodanish / stopwatch.js
Created December 27, 2021 11:11
stop watch in js
var timer = document.getElementById("timer");
var idealTimer = document.getElementById("ideal");
var runningId;
var idealId;
var value = "0:0";
var Idealvalue = "00:00";
function startTimer(m, s) {
value = m + ":" + s;
if (s == 60) {
m = m + 1;
@mailtodanish
mailtodanish / identify_router.py
Created December 27, 2021 18:49
Algorithm that can detect the routers with the highest number of connections
# 1 -> 2 -> 3 -> 5 -> 2 -> 1
sample_input_graph_dict_1={
"1":["2"],
"2":["3","1"],
"3":["5"],
"4":[],
"5":["2"],
"6":[],
}
# 1 -> 3 -> 5 -> 6 -> 4 -> 5 -> 2 -> 6
@mailtodanish
mailtodanish / datum.js
Created January 14, 2022 06:50
add datum in output transaction
const datums = this.S.PlutusList.new();
const datum = this.S.PlutusData.new_constr_plutus_data(
this.S.ConstrPlutusData.new(
this.S.Int.new_i32(1),
this.S.PlutusList.new()
)
);
datums.add(datum);
console.log("datums", datums);
@mailtodanish
mailtodanish / datum.js
Created January 14, 2022 07:53
create datum.json using Plutus
//using cardano-serialization-lib
const plutusList = CSL.PlutusList.new();
plutusList.add(CSL.PlutusData.new_bytes(Buffer.from('3f7826896a48c593598465a096d63606ceb8206', 'hex')));
plutusList.add(CSL.PlutusData.new_integer(CSL.BigInt.from_str('1888')));
plutusList.add(CSL.PlutusData.new_integer(CSL.BigInt.from_str('1')));
CSL.PlutusData.new_constr_plutus_data(CSL.ConstrPlutusData.new(CSL.Int.new_i32(0), plutusList));
'''
{
"constructor":0,
#this is complex
thickness = 9
c = 'H'
for i in range(thickness):
print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1))
# Read input from STDIN. Print output to STDOUT
# Size: 7 x 21
# ---------.|.---------
# ------.|..|..|.------
# ---.|..|..|..|..|.---
# -------WELCOME-------
# ---.|..|..|..|..|.---
# ------.|..|..|.------
# ---------.|.---------
import matplotlib.pyplot as plt
p1 = [1, 1]
p2 = [5, 3]
p3 = [2, 3]
x_values = [p1[0], p2[0]]
y_values = [p1[1], p2[1]]
plt.plot(x_values, y_values, 'bo', linestyle="--")
plt.xlim(0, 6), plt.ylim(0, 6)
# Given an integer, , print the following values for each integer from to :
# Decimal
# Octal
# Hexadecimal (capitalized)
# Binary
hexa_digit = {
0: 0,
1: 1,