Skip to content

Instantly share code, notes, and snippets.

View ratozumbi's full-sized avatar

Bruno Willian Andrade ratozumbi

View GitHub Profile
@ratozumbi
ratozumbi / ExportCSV.cs
Created June 22, 2023 17:28
exemple on how to create a CSV file
public void ExportCSV()
{
string[] tableNames =
{
"especialidade", "participante", "perfil",
"pergunta", "resposta", /*"questao",*/"quiz",
"setor", "tecnologia", "treinamento", "empresa"
};
using (IDbConnection dbcon = new SqliteConnection(DataManager.Instance.Connection))
@ratozumbi
ratozumbi / Exemple.cs
Created January 23, 2023 21:55
Get thumbnail from video (Unity3D)
 //From: https://forum.unity.com/threads/skipping-to-video-frame-not-working-on-android.930021/#post-6173383
public void PrepareVideoForPlayback() {
Benchmark("Prepare Video Player for " + media.path);
videoPlayer.url = media.path;
videoPlayer.source = VideoSource.Url;
videoPlayer.renderMode = VideoRenderMode.APIOnly;
videoPlayer.prepareCompleted += OnVideoPrepareCompleted;
videoPlayer.Prepare();
}
 
@ratozumbi
ratozumbi / SeriDic.cs
Created September 22, 2022 15:06
Fake serializable dictionary
//credits: https://forum.unity.com/threads/finally-a-serializable-dictionary-for-unity-extracted-from-system-collections-generic.335797/
[Serializable]
public class MyDictionaryEntry
{
public GameObject key;
public float value;
}
[SerializeField]
@ratozumbi
ratozumbi / SerializableDictionary.cs
Created September 16, 2022 18:16
WIP serializable dictionary
#nullable enable
using System;
using System.Collections.Generic;
using UnityEngine;
public interface ISerializableDictionaryKey
{
public ISerializableDictionaryKey GetNewKey();
}
@ratozumbi
ratozumbi / PixelManipulation.cs
Created September 5, 2022 19:05
Alpha blend, gray scale and sepia
public Texture2D ToGrayScale(Color[] cArr)
{
var bottomPixelData = cArr;
int count = bottomPixelData.Length;
var resultData = new Color[count];
for(int i = 0; i < count; i++)
{
Color bottomPixels = bottomPixelData[i];
Color temp = new Color(
(1f-bottomPixels.r),
@ratozumbi
ratozumbi / TextureFormatCheck
Created September 2, 2022 20:12
Check valid TextureFormat for current platform Unity3D C#
var types = Enum.GetValues(typeof(TextureFormat));
try
{
foreach (var type in types)
{
if(SystemInfo.SupportsTextureFormat((TextureFormat)type))
Debug.Log(Enum.GetName(typeof(TextureFormat),type));
}
@ratozumbi
ratozumbi / AutodetectPorts.cs
Created May 17, 2021 03:02
Autodetect Arduino board on Windows
using Microsoft.Win32;
using System.Collections.Generic;
using System.IO.Ports;
namespace SerialManagement
{
public static class AutodetectPorts
{
public class ArduinoPort
{
@ratozumbi
ratozumbi / PrintManager.cs
Created March 24, 2021 06:31
Save webcam with grayscale filter and alpha blend
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Fotoprint
{
public class PrintManager : MonoBehaviour
{
@ratozumbi
ratozumbi / sqlite_variables.sql
Last active February 2, 2021 00:01
How to use variables in SQLite
PRAGMA temp_store = 2;
CREATE TEMP TABLE _Variables(Name TEXT PRIMARY KEY, RealValue REAL, IntegerValue INTEGER, BlobValue BLOB, TextValue TEXT);
/*pergunta 1 linha 3*/
insert into main.pergunta (descricao, dificuldade, cod_quiz, cod_especialidade) values ('Podemos utilizar o cateter Power PICC® para infusão de contraste?', 1, 1, 7);
/* Declaring a variable */
INSERT INTO _Variables (Name, IntegerValue) VALUES ('pergunta_id',(SELECT last_insert_rowid()) );
-- UPDATE _Variables SET IntegerValue = (SELECT last_insert_rowid()) WHERE Name = 'pergunta_id';
@ratozumbi
ratozumbi / hash_compare_files.py
Created May 28, 2020 17:55
python script that hashes files recursively then compare each one to find duplicates
import hashlib
import os
def getHashes(path, fileHashes):
print("executing in "+ path)
for filename in os.listdir(path):
fullpath = os.path.join(path,filename)
if os.path.isfile(fullpath):