Skip to content

Instantly share code, notes, and snippets.

View TheOnlyWayUp's full-sized avatar
📰
Democratizing information

Dhanush R TheOnlyWayUp

📰
Democratizing information
View GitHub Profile
import pkg_resources
from subprocess import call
packages = [dist.project_name for dist in pkg_resources.working_set]
#Uses list comprehension to create a list of all packages installed, and then get their names.
call("pip install --upgrade " + ' '.join(packages), shell=True)
#Call is like os.system, it runs pip install upgrade and the join essentially seperates all the packages with a " ", ex if you had the packages discord and setuptools installed, the list would become ["discord", "setuptools"] and it would run pip install -upgrade discord setuptools
from __future__ import print_function, division
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Keras modules
from tensorflow.keras.layers import Input, Dense, Reshape, Flatten, Dropout, BatchNormalization, Activation, ZeroPadding2D, LeakyReLU, UpSampling2D, Conv2D
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.optimizers import Adam
@Rafastoievsky
Rafastoievsky / cleaningdatafunctions.py
Created November 2, 2020 02:45
WhatsApp Group chat analysis: cleaning data functions
def startsWithDateAndTime(s):
pattern = '^\d{1,2}/\d{1,2}/\d{1,2}, \d{1,2}:\d{1,2}\S [AaPp][Mm] -'
result = re.match(pattern, s)
if result:
return True
return False
def FindAuthor(s):
patterns = [
'([\w]+):', # Nombre
@JeyyGit
JeyyGit / modal_implementation_example.py
Last active March 4, 2022 20:32
Rough implementation of modal in discord.py 2
import discord, secrets
class TextInput:
"""for storing our text input data"""
def __init__(self, payload):
self.type = payload['type']
self.custom_id = payload['custom_id']
self.style = payload['style']
self.label = payload['label']
self.min_length = payload.get('min_length')
@TheOnlyWayUp
TheOnlyWayUp / imageFunctions.py
Last active March 6, 2022 14:01
Example of BytesIO and PIL for modifying images without saving them
domain = 'watermark' # just an example of how to use bytesio with PIL, works better if you know more about the images you're using instead of using random ones which can have random dimensions.
import aiohttp
from urllib.parse import unquote
from io import BytesIO
from PIL import Image, ImageDraw, ImageFont
async def returnRandomCat():
async with aiohttp.ClientSession() as session:
async with session.get("https://aws.random.cat/meow") as resp:

Fun fact : a lightbulb has been on since 1901 in a region of siberia. Ivan Popov discovered that electricity could be extracted from the ground in the region as the soil is mineral rich, and the water table is high. This discovery has allowed the earth to accomplish this remarkable feat

Fun fact : the covalent character of ionic bonds was discovered as a result of a similar mathematical error. George Smith made a mathematical error while calculating the lattice energy of a compound, and ended up with the result he expected despite the error. When his assistant discovered the error, he devised the theory used today

Fun fact : Hydrated salts were the result of a paranoid geologist. Johnathan Everard began the practice of baking samples obtained in the field to kill microbes, believing that doing so would prevent him from contracting tetanus. A difference in mass before and after baking observed with one of the samples led him to this path paving discovery

Fun fact : In 2015 Dalia Scott, a student at the M

@ItsDrike
ItsDrike / 1_basic_autoinit.py
Last active May 6, 2022 22:06
Python auto_init
"""
This attempts to abstarct away the standard way of using `__init__`,
the problem it tries to solve is the repetetiveness of using init purely
to store it's parameters into the instance under the exactly same name, i.e.:
class Stock:
def __init__(name, shares, price):
self.name = name
self.shares = shares
self.price = price
"""
@eaorak
eaorak / hangman.py
Created October 31, 2012 09:59
Python - Hangman Game
#!/usr/bin/python3
# Hangman game
import random
class HangMan(object):
# Hangman game
hang = []
hang.append(' +---+')
from wpf import *
# Create window
my_window = Window()
my_window.Title = 'Welcome to IronPython'
# Create StackPanel to Layout UI elements
my_stack = StackPanel()
my_stack.Margin = Thickness(15)
my_window.Content = my_stack
#! /usr/bin/env python3
import select
import socket
import time
TIME_WAIT = 0.01
BIND_ADDR = ''
BIND_PORT = 8443
SERV_ADDR = 'server.example.com'