Skip to content

Instantly share code, notes, and snippets.

View ivanvoid's full-sized avatar
🏠
Working from home

Ivan Kakhaev ivanvoid

🏠
Working from home
  • Taiwan
View GitHub Profile
@ivanvoid
ivanvoid / gist:80f38ceb1ca5a3e6fa979a5f0831b290
Last active May 27, 2023 04:47
Godot_v4_signal_pattern.txt
# insted of this
$Button.connect("pressed", self, "_on_button_pressed")
# you do this
$Button.pressed.connect(self._on_button_pressed)
@ivanvoid
ivanvoid / main.py
Created November 9, 2021 02:57
dataframe shuffler
def shuffle(data):
data = data.iloc[np.random.permutation(len(data))]
data = data.reset_index(drop=True)
return data
@ivanvoid
ivanvoid / main.py
Created November 9, 2021 02:46
turnung categorical values to numerical once
# turnung categorical values to numerical once
def name2num(name):
return [all_letters.index(l) for l in name]
def num2name(num):
return [all_letters[n] for n in num]
def category2num(c):
return all_categories.index(c)
def num2category(num):
return all_categories[num]
@ivanvoid
ivanvoid / main.py
Created November 9, 2021 02:39
dict to dataframe
# transform data from dict to dataframe
import pandas as pd
from tqdm import tqdm
data = pd.DataFrame(columns=['category', 'name'])
for category in tqdm(all_categories):
names = category_lines[category]
for name in names:
frame = {'category':category, 'name':name}
@ivanvoid
ivanvoid / main.py
Created November 9, 2021 02:27
loading data
# Load data from files to dict
import os
import glob
import string
import unicodedata
all_letters = string.ascii_letters + " .,;'-"
category_lines = {}
all_categories = []
@ivanvoid
ivanvoid / main.py
Created November 9, 2021 02:09
seggan unzipper
# Unpuck zip file
from zipfile import ZipFile
with ZipFile(data_fn, 'r') as zip_obj:
zip_obj.extractall()
# loading data from the web
import requests
data_fn = 'data.zip'
data_url = 'https://download.pytorch.org/tutorial/data.zip'
f = requests.get(data_url).content
open(data_fn, 'wb').write(f)