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 sys | |
from tweepy import OAuthHandler | |
from tweepy import API | |
from tweepy import Stream | |
from tweepy.streaming import StreamListener | |
# Replace the "None"s by your own credentials | |
ACCESS_TOKEN = None | |
ACCESS_TOKEN_SECRET = None |
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
#!/bin/python3 | |
#-*- encoding: utf-8 -*- | |
import slackweb | |
HOOK_URL='https://hooks.slack.com/services/SOME_GIBBERISH_CODE.' | |
slack = slackweb.Slack(url=HOOK_URL) | |
slack.notify(text="Hello world!") |
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 datetime import datetime | |
(datetime.today().strftime("%Y年%m月%d日")) | |
"{:%Y年%m月%d日}".format(datetime.today()) | |
"{0:%Y}{1}{0:%m}{2}{0:%d}{3}".format(datetime.today(), "年", "月", "日") | |
f"{datetime.today():%Y年%m月%d日}" |
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 torchvision import datasets, transforms | |
from torch.utils.data import DataLoader | |
from torch.optim import Adam | |
from torch import nn | |
transform=transforms.Compose([ | |
transforms.ToTensor(), | |
transforms.Normalize((0.1307,), (0.3081,)) | |
]) | |
dataset = datasets.MNIST('./mnist_data', train=True, download=True, |
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 torch | |
from torch import nn | |
import torch.nn.functional as F | |
class Perceptron(nn.Module): | |
def __init__(self): | |
super().__init__() | |
self.dropout2 = nn.Dropout(0.5) | |
self.fc1 = nn.Linear(28 * 28, 128) # 9216 | |
self.fc2 = nn.Linear(128, 10) |
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 tqdm import tqdm | |
lst = [1, 3, 5, 7, 11] | |
for element in tqdm(lst): | |
sleep(0.1) |
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 tqdm import trange | |
iterations = 20 | |
for i in trange(iterations, desc="Proving P=NP", unit="carrots"): | |
sleep(0.1) |
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 get_divisors(n): | |
divisors = [] | |
for m in range(1, n+1): | |
if n % m == 0: | |
divisors.append(m) | |
return divisors |
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 tqdm import trange | |
iterations = 10 | |
pbar = trange(iterations, unit="carrots") | |
for i in pbar: | |
sleep(0.5) | |
if i % 2: | |
pbar.set_description(f"Testing odd number {i}") | |
else: | |
pbar.set_description(f"Testing even number {i}") |
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 tqdm import trange | |
iterations = 10 | |
with trange(iterations, unit="carrots") as pbar: | |
for i in pbar: | |
sleep(0.5) | |
if i % 2: | |
pbar.set_description(f"Testing odd number {i}") | |
else: | |
pbar.set_description(f"Testing even number {i}") |
OlderNewer