View vowels_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
View prime_numbers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
View filetype.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View ibm_cos_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View Levenshtein Distance - Using fuzzywuzzy package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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. |
View promise.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author: Aashish | |
* Date: 13-07-2019 | |
*/ | |
import java.util.*; | |
class Solution { | |
static class Graph { |
NewerOlder