This file contains hidden or 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 _decode_unicode_escape_in_dict_(target_dict): | |
| new_dict = {} | |
| for key1, value1 in target_dict.items(): | |
| key1 = key1.encode().decode("unicode-escape") | |
| if isinstance(value1, dict): | |
| value1 = _decode_unicode_escape_in_dict_(value1) | |
| elif isinstance(value1, str): | |
| value1 = value1.encode().decode("unicode-escape") | |
| new_dict[key1] = value1 | |
| return new_dict |
This file contains hidden or 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 numpy as np | |
| import matplotlib.pyplot as plt | |
| from mpl_toolkits.mplot3d import Axes3D | |
| def beta_test(): | |
| b = np.random.beta(1,2,2000) | |
| b0 = np.random.beta(1,1,1000) | |
| x = np.random.uniform(0,1,2000) | |
| x = x.reshape((-1,2)) | |
| b1 = (1 - (1 - x) ** (1/2 + 0j)).real |
This file contains hidden or 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
| # python file amalgamation example (amalgamate cpython into one file) | |
| import os | |
| target_folder_name = r"repo\cpython" | |
| output_file_name = "cpython.txt" | |
| with open(output_file_name, "xb") as o_f: | |
| for root, dirs, files in os.walk(target_folder_name): | |
| for name in files: | |
| _, ext = os.path.splitext(name) |
This file contains hidden or 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 os | |
| import errno | |
| import cv2 | |
| import torch | |
| import numpy as np | |
| import random | |
| from torch.utils.data import Dataset, ConcatDataset, DataLoader | |
| from typing import Callable | |
This file contains hidden or 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
| a = [] | |
| a.append(a) | |
| while len(a) >= 1: | |
| print(a) | |
| a = a[0] | |
| import copy | |
| b = copy.deepcopy(a) | |
| print(b) |
This file contains hidden or 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
| # St. Petersberg paradox simulation | |
| # https://en.wikipedia.org/wiki/St._Petersburg_paradox | |
| import numpy as np | |
| rng = np.random.default_rng(seed=42) | |
| def geometric(): | |
| """Play one game of 'st_petersberg paradox' by simulating coin throws. |
This file contains hidden or 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
| https://pastebin.com/d9HsbeBE |
This file contains hidden or 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 requests | |
| import csv | |
| # import unicodecsv as csv | |
| from time import sleep | |
| from random import normalvariate | |
| from bs4 import BeautifulSoup | |
| pagenum_range = range(829, 844) | |
| filename = 'kin.csv' |
This file contains hidden or 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 <stdio.h> | |
| int main(void){ | |
| printf("Hello world!\n"); | |
| return 0; | |
| } |
NewerOlder