Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Furiously Coding

Aashish Chaubey aashish-chaubey

💻
Furiously Coding
View GitHub Profile
@aashish-chaubey
aashish-chaubey / vowels_name.py
Created Aug 6, 2022
Count all the vowels in the name and show count of each of them
View vowels_name.py
from collections import Counter
name = "Aashish Chaubey"
vowels = "aeiou"
vowels_list = list(filter(lambda x: x in vowels, name.lower()))
print(f"Number of vowels in name is: {len(vowels_list)}")
print(dict(Counter(vowels_list)))
@aashish-chaubey
aashish-chaubey / prime_numbers.py
Created Aug 6, 2022
Find all the numbers between 1-50 and print them in a list
View prime_numbers.py
import math
l = 50
def is_prime(num: int) -> bool:
lim = math.floor(math.sqrt(num))
for i in range(2, lim+1):
if num % i == 0:
return False
return True
View task_of_pairing.py
def taskOfPairing(freq):
count = 0
marker = False
for i in freq:
if i != 0:
count += i // 2
if i % 2 != 0 and marker:
count += 1
marker = False
elif i % 2 != 0:
View consective_months.py
import pandas as pd
df = pd.DataFrame({'agent_id': [1, 1, 1, 1, 2, 2, 2, 2],
'date': ["2021-01-01", "2021-04-01", "2021-05-01", "2021-06-01", "2021-01-01", "2021-02-01", "2021-03-01", "2021-06-01"],
'txn_amount': [100, 200, 100, 200, 100, 200, 100, 200],
'txn_status': ["Failure", "Success", "Failure", "Success", "Failure", "Success", "Failure", "Success"]})
df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d')
df1 = df.set_index('date')
View firebase_create_user.py
import firebase_admin
from firebase_admin import credentials
from firebase_admin import auth
cred = credentials.Certificate('secreatFile.json')
default_app = firebase_admin.initialize_app(cred)
# Search a user by email, ig registered
user = auth.get_user_by_email('chaubey.aashish@gmail.com')
@aashish-chaubey
aashish-chaubey / filetype.py
Last active Feb 14, 2020
Checking if the file binary is a RIFF type or any other type
View filetype.py
start_text = "RIFF"
import os
for i, filename in enumerate(os.listdir('./')):
with open(filename, 'rb') as imageFile:
if imageFile.read().startswith(b'RIFF'):
print(f"{i+1}: {filename} - found!")
else:
continue
@aashish-chaubey
aashish-chaubey / ibm_cos_data.py
Created Jan 12, 2020
Python Code to pull out data from IBM Cloud Object Store
View ibm_cos_data.py
import ibm_boto3
from ibm_botocore.client import Config, ClientError
# Constants for IBM COS values
COS_ENDPOINT = # Current list avaiable at https://control.cloud-object-storage.cloud.ibm.com/v2/endpoints
COS_API_KEY_ID = # eg "W00YiRnLW4a3fTjMB-odB-2ySfTrFBIQQWanc--P3byk"
COS_AUTH_ENDPOINT = "https://iam.cloud.ibm.com/identity/token"
COS_RESOURCE_CRN = # eg "crn:v1:bluemix:public:cloud-object-storage:global:a/3bf0d9003abfb5d29761c3e97696b71c:d6f04d83-6c4f-4a62-a165-696756d63903::"
# Create resource
@aashish-chaubey
aashish-chaubey / Levenshtein Distance - Using fuzzywuzzy package
Created Oct 30, 2019
Using the fuzzywuzzy package to calculate the distance between 2 strings
View Levenshtein Distance - Using fuzzywuzzy package
### Using the fuzzywuzzy package
fuzzywuzzy package in python implements the Lavenshtein distance between two string to calculate the similarity between the two.
Install 2 packages:
pip install fuzzywuzzy
pip install python-Levenshtein / conda install -c conda-forge python-levenshtein
`[I actually had an issue installing the package, so I used the conda installation for this this package]`
This package is required to suppress the warning for the default slow fuzzywuzzy package.
@aashish-chaubey
aashish-chaubey / promise.js
Created Aug 20, 2019
Implementing and using the basic promise
View promise.js
/**
* @author Aashish Chaubey
* @link https://github.com/aashish-chaubey
*/
/**
* First Create a Promise my implementing it with a `new` keyword
* Do all the heavy weight operations in the promise
* Store the promise in a variable
*/
View Solution.java
/**
* @author: Aashish
* Date: 13-07-2019
*/
import java.util.*;
class Solution {
static class Graph {