Skip to content

Instantly share code, notes, and snippets.

View mariodivece's full-sized avatar

Mario Di Vece mariodivece

View GitHub Profile
@mariodivece
mariodivece / StringEx.hh
Last active December 27, 2023 12:56
A C++ string class designed for embedded systems
// online dev: https://www.onlinegdb.com/online_c++_compiler
#include <cstring>
#include <iostream>
#include <cstdarg>
#include <algorithm>
using namespace std;
class StringEx {
@mariodivece
mariodivece / mad-scanlines-crt.glsl
Last active March 10, 2024 04:16
CRT Scanline Effect for Dolphin Emulator
void main()
{
float currentMillis = GetTime() / float(1000.0);
float2 coords = GetCoordinates();
float lineCount = GetWindowResolution().y / 2.0;
// scanlines
int lineIndex = int( ( coords.y + currentMillis * 0.5 ) * lineCount );
#ifdef API_OPENGL
float lineIntensity = mod(float(lineIndex), 2);
@mariodivece
mariodivece / scanlines.glsl
Last active March 10, 2024 16:02
A simple, configurable GLSL scanline effect shader for Dolphin
/*
[configuration]
[OptionRangeFloat]
GUIName = Blur Area
OptionName = BLUR_SIZE
MinValue = 0.0
MaxValue = 10.0
StepAmount = 0.1
DefaultValue = 1.6
@mariodivece
mariodivece / MultimediaTimer.cs
Created July 24, 2017 01:56
A timer based on the multimedia timer API with approximately 1 millisecond precision.
namespace Unosquare.FFME.Core
{
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// A timer based on the multimedia timer API with approximately 1 millisecond precision.
@mariodivece
mariodivece / GT511C3.cs
Created April 17, 2016 00:19
A very simple wrapper to control the popular fingerprint reader model GT511C3
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Unosquare.Devices
{
public class GT511C3 : IDisposable
@mariodivece
mariodivece / CsvWriter.cs
Created January 15, 2015 14:41
CSV Writer
namespace Unosquare.Utils
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@mariodivece
mariodivece / MakeComboBoxSearchable.cs
Created January 3, 2015 07:15
Makes a WPF ComboBox Searchable via its items
public static void MakeComboBoxSearchable(this ComboBox targetComboBox)
{
targetComboBox.Loaded += (ls, le) =>
{
targetComboBox.Items.IsLiveFiltering = true;
var targetTextBox = targetComboBox.Template.FindName("PART_EditableTextBox", targetComboBox) as TextBox;
if (targetTextBox == null) return;
targetComboBox.IsEditable = true;
@mariodivece
mariodivece / CircleOffset.cs
Created May 20, 2014 01:39
Extension methods that perform circular-addressing math on 0-index based arrays
namespace Unosquare.Utilities
{
public static class Extensions
{
static public int CircleOffset(this int currentIndex, int offset, int lastIndex)
{
var newIndex = currentIndex + offset;
return newIndex.CircleIndex(lastIndex);
}
namespace Unosquare.Wpf
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public abstract class DimensionalObjectBase : ViewModelBase
{
@mariodivece
mariodivece / ViewModelBase.cs
Last active April 18, 2023 02:23
A simple ViewModelBase for WPF Apps
namespace Unosquare.Wpf
{
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
public abstract class ViewModelBase : INotifyPropertyChanged
{
// uncomment the line below for Log4Net Logging