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
public static int GetCurrentTime() | |
{ | |
System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); | |
int cur_time = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds; | |
return cur_time; | |
} |
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
using System.IO; | |
using (var fileStream = new FileStream(file_path, FileMode.Append, FileAccess.Write, FileShare.None)) | |
using (var bw = new BinaryWriter(fileStream)) | |
{ | |
bw.Write(0.0f); | |
byte[] lotsOfData; | |
bw.Write(lotsOfData); | |
} |
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
private void ReadBinFile(string path, System.Action<Vector3, float> f) | |
{ | |
if (!File.Exists(path)) //if file does not exist we will not try reading it | |
{ | |
return; | |
} | |
BinaryReader br; | |
//reading from the file |
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 uuid | |
import os | |
def get_extension(name): | |
return name.split('.')[-1] | |
def get_list_of_files_only_in_folder(folder_path): | |
return [f for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))] # | |
def rename_all_files_inside_folder(folder_path): |
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 uuid | |
#How to generate random uuid? | |
print(str(uuid.uuid4())) |
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
from PIL import Image | |
import os | |
def resizeImage(path_input, new_size): | |
folder = os.path.dirname(path_input) | |
name = os.path.basename(path_input) | |
out_file_extension = name.split('.')[-1] #you can use different than input if needed | |
img = Image.open(path_input) | |
img = img.resize((new_size[0],new_size[1]), Image.ANTIALIAS) |
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 | |
def getPartsOfPath(path): | |
path_to_folder = os.path.dirname(path) | |
file_name_with_extension = os.path.basename(path) | |
file_name_without_extension, extension = os.path.splitext(file_name_with_extension) | |
return (path_to_folder, file_name_with_extension, file_name_without_extension, extension) | |
getPartsOfPath("C:\\Users\\C\\Desktop\\Cosmos\\test.png") |
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
public static void SetBaseColorMap(ref Renderer renderer, in RenderTexture render_texture) | |
{ | |
renderer.material.SetTexture("_BaseColorMap", render_texture); | |
} |
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
//Make sure to enable the Keywords (You may not need todo this in a loop) | |
rend.material.EnableKeyword("_NORMALMAP"); | |
rend.material.EnableKeyword("_METALLICGLOSSMAP"); | |
//After that you can use this | |
rend.material.SetTexture("_MainTex", result_render_texture); |
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
#you need to have installed pydub and conda | |
#conda install -c conda-forge ffmpeg | |
#conda install -c conda-forge pydub | |
from pydub import AudioSegment | |
path_file_input = "C://Users//X//Downloads//t_voice5812054872861705901.ogg" | |
path_file_output = "C://Users//X//Desktop//bip//audioX.mp3" | |
ogg_version = AudioSegment.from_ogg(path_file_input) | |
ogg_version.export(path_file_output, format="mp3") |