Skip to content

Instantly share code, notes, and snippets.

@Infinitusvoid
Infinitusvoid / main.cpp
Created January 15, 2023 20:34
C++ : Examples of virtual functions, without them, and with templates.
#include <iostream>
#include <string>
namespace Without_virtual_functions
{
// Without virtual functions
struct Shape
{
std::string description()
{
@Infinitusvoid
Infinitusvoid / main.cpp
Created January 15, 2023 20:02
C++ : Type punning examples
#include <iostream>
struct Entity
{
int x;
int y;
int* get_position()
{
return &x;
@Infinitusvoid
Infinitusvoid / file_0.cpp
Created January 15, 2023 19:24
C++ : What does static mean outside the class or struct ?
#include <iostream>
int variable_v0 = 500;
void func_a()
{
std::cout << "I am func_a" << std::endl;
}
static void func_b()
@Infinitusvoid
Infinitusvoid / main.cpp
Last active January 15, 2023 14:02
C++ : How to use std::async and std::future to push to vector from multiple threads ( multithreading, threads )?
#include <iostream>
#include <future>
static std::mutex s_ElementMutex;
std::vector<std::future<void>> futures;
struct Element
{
int i;
double b;
@Infinitusvoid
Infinitusvoid / example.py
Last active August 30, 2023 16:01
Blender Python : How to create two cubes, and apply remesh modifier to merge them ?
import bpy
# Create first cube
bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0))
# Create second cube
bpy.ops.mesh.primitive_cube_add(size=1, location=(1, 0, 0))
# Get the active object (the last one created)
obj = bpy.context.active_object
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 5 columns, instead of 4 in line 5.
Question ID (machine readable),Response ID (machine readable),Response value,Answer requirement,Human-friendly question label
PSL_DATA_COLLECTION_COLLECTS_PERSONAL_DATA,,false,REQUIRED,Does your app collect or share any of the required user data types?
PSL_DATA_COLLECTION_ENCRYPTED_IN_TRANSIT,,,MAYBE_REQUIRED,Is all of the user data collected by your app encrypted in transit?
PSL_DATA_COLLECTION_USER_REQUEST_DELETE,,,MAYBE_REQUIRED,Do you provide a way for users to request that their data is deleted?
PSL_DATA_COLLECTION_COMPLIES_FAMILY_POLICY,,,OPTIONAL,"Only answer this question if you've indicated that your app's target age group includes children, or you've opted into the Designed for Families program. If either of the above is true, you are required to follow the Google Play Families Policy (https://support.google.com/googleplay/android-developer/answer/9893335). Do you want to let users know about this commitment in the Data safety section on your store listing?"
PSL_INDEPENDENTLY_VALIDATED,,true,OPTIONA
@Infinitusvoid
Infinitusvoid / EulerToSpherical.cs
Last active August 24, 2023 22:26
Unity : How to convert cartesian coordinates to spherical coordinates system ?
public static (float radius, float theta, float phi) EulerToSpherical(Vector3 p)
{
float radius = Mathf.Sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
float theta = Mathf.Acos(p.z / radius);
float phi = Mathf.Atan2(p.y, p.x);
return (radius, theta, phi);
}
@Infinitusvoid
Infinitusvoid / NameOfVariable.cs
Created September 13, 2021 09:44
C# : How do we get the name of variable ?
int jupij = 10;
string name = nameof(jupij);
Debug.Log("name of variable : " + name);
@Infinitusvoid
Infinitusvoid / MoveGameObjectToSeperateSceneAtRuntime.cs
Created August 12, 2021 11:05
Unity C# : How to create a scene in runtime and move objects to separate scene?
//using UnityEngine.SceneManagement;
//Create a scene and move Object to sepeate scene?
Scene pool_scene = SceneManager.CreateScene("PoolScene");
for (int i = 0; i < list_of_gameobjects.Count; i++)
{
SceneManager.MoveGameObjectToScene(
list_of_gameobjects[i], pool_scene
);
}
@Infinitusvoid
Infinitusvoid / NormalizedDirectionVector3.cs
Created May 25, 2021 11:19
Unity : How to get vector that represents normalized direction from vector to vector?
public static Vector3 DirectionTo(this Vector3 source, Vector3 destination)
{
return Vector3.Normalize(destination - source);
}