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 pathlib import PurePath, Path | |
def stringify_file(filename: str) -> str: | |
single_file = "" | |
with open(filename) as file: | |
for line in file: | |
if len(line.strip()) > 0: | |
line = line.split('#') | |
if len(line) == 1: # the line has comments, then ignore them |
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
#include <iostream.h> //example of operator overloading | |
template<class T> | |
class Stack { | |
public: | |
Stack(int n); | |
Stack(Stack<T>& s); //copy constructor | |
~Stack() {delete [] stackPtr;} // destructor | |
Stack<T> operator + (const Stack<T>& s2) const; //overloading + | |
Stack<T>& operator = (const Stack<T>& s); //overloading assignment |
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 | |
import pandas as pd | |
filename = sys.argv[1] | |
filename = filename[:-4] | |
read_file = pd.read_csv (filename + ".csv") | |
read_file.to_excel (filename + ".xlsx", index = None, header=True) | |
# run as | |
# python csv_to_xlsx.py %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 tensorflow.keras import Model | |
from tensorflow.keras.layers import Convolution2D | |
from tensorflow.keras.layers import MaxPool2D | |
from tensorflow.keras.layers import BatchNormalization | |
from tensorflow.keras.layers import Input | |
from tensorflow.keras.layers import Flatten | |
from tensorflow.keras.layers import Dropout | |
from tensorflow.keras.layers import Dense | |
from tensorflow.keras.layers import concatenate | |
from tensorflow.keras.optimizers import Adam |
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
#include <windows.h> | |
#include <GLFW/glfw3.h> | |
#include <iostream> | |
// change this to int main() to allow the console | |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char*, int nShowCmd) | |
{ | |
GLFWwindow* window; | |
int windowSizeW = 640, windowSizeH = 480; | |
// initialize the library |
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
#include <iostream> | |
#include <string> | |
#include <sstream> | |
template <typename T> | |
std::string to_string_with_precision(const T a_value, const int n = 4) | |
{ | |
std::ostringstream out; | |
out.precision(n); | |
out << std::fixed << a_value; |
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 scipy.io as scio | |
from typing import Any, Dict | |
import numpy as np | |
def load_matfile(filename: str) -> Dict: | |
def parse_mat(element: Any): | |
# lists (1D cell arrays usually) or numpy arrays as well | |
if element.__class__ == np.ndarray and element.dtype == np.object_ and len(element.shape) > 0: | |
return [parse_mat(entry) for entry in element] |
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
# first, install requests and matplotlib (pip install requests matplotlib) | |
from urllib.request import urlopen | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
import requests | |
api_url_pokemon = 'https://pokeapi.co/api/v2/pokemon/pikachu' | |
result = requests.get(api_url_pokemon) | |
if result.status_code == 200: | |
pokemon_data = result.json() |
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 scipy.stats import describe | |
import numpy as np | |
# arr_values is a numpy array | |
def print_stats(arr_values: np.array) -> None: | |
stats = describe(arr_values) | |
print(f'min: {stats.minmax[0]:.5f}, max: {stats.minmax[1]:.4f}') | |
print(f'mean: {stats.mean:.5f}') | |
print(f'standard: {np.std(arr_values):.5f}') | |
print(f'variance: {stats.variance:.5f}') |
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
@echo off | |
REM Remove files generated by compiler in this directory and all subdirectories. | |
REM Essential release files are kept. | |
echo Removing "*.csproj.user" files... | |
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.csproj.user"') do del "%%i" /f /q | |
echo. | |
echo Removing "*.exe.config" files... |
NewerOlder