Skip to content

Instantly share code, notes, and snippets.

@Maxstupo
Maxstupo / Win32FileScanner.cs
Last active April 23, 2020 05:40
C# FileScanner using FindFirstFile and FindNextFile with optional directory statistics
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace Maxstupo.Utility {
public enum FileType {
File = 0,
Folder = 1
@Maxstupo
Maxstupo / CustomerRepository.cs
Last active February 8, 2023 20:47
Concept for a Data Access Layer using SQLite, Dapper, and the Repository Pattern.
using Dapper;
using Dal;
using System.Collections.Generic;
using System.Threading.Tasks;
// Example implementation of the GenericRepository
// Our model.
public class Customer {
@Maxstupo
Maxstupo / Canvas.cs
Created July 12, 2019 15:59
A control suitable for drawing 2D graphics, with zoom and pan functionality.
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Maxstupo.Controls {
/// <summary>
/// Provides a surface suitable for drawing 2D graphics, with zoom and pan functionality.
/// </summary>
@Maxstupo
Maxstupo / nas_plex_installer.sh
Last active January 23, 2020 09:39
Ubuntu Media NAS (Samba & Plex + Webmin)
#!/bin/bash
#
# ----- WARNING: This script is a work in progress ------
#
# NAS Media Server Install Script
#
# Installs SSH, Webmin, Samba, and Plex.
# Upgrade
@Maxstupo
Maxstupo / Ads.java
Created July 29, 2018 06:11
A helper class for AdMob ads
import android.app.Activity;
import android.location.Location;
import android.view.View;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
/*
@Maxstupo
Maxstupo / JQueryTemplate.plugin.js
Last active December 21, 2018 05:46
A jQuery plugin template.
(function ($) {
const PLUGIN_NAME = 'myplugin'; // The name of the plugin method. (Function name of the plugin)
const DATA_NAME = 'jqp_' + PLUGIN_NAME; // The id of the plugin instance attached to each element that this plugin was initialized on. (https://api.jquery.com/data/)
const MyPlugin = function ($el, newOptions) {
const _this = this;
this.$el = $el; // Expose jQuery object this plugin is attached to.
/* ---------------- Options Setup --------------- */
@Maxstupo
Maxstupo / ObjectPool.cs
Last active May 21, 2020 10:46
A generic object pool in C#
using System;
using System.Collections.Generic;
//TODO: Implement the IDisposable interface to allow pooled objects to be freed by the using keyword.
public interface IPoolable {
void ResetObject();
}
public abstract class ObjectPool<T> where T : IPoolable {
@Maxstupo
Maxstupo / EventSystem.js
Last active February 8, 2018 13:14
A event system to provide event handling.
/**
* The EventSystem provides basic event handling.
*
* A basic example:
* <pre><code>
* let es = new EventSystem();
*
* let listenerId = es.on('myEvent', function() { // Register a new event listener for the event 'myEvent'.
* console.log('Hello World!!');
* });
@Maxstupo
Maxstupo / MovementController.cs
Created April 3, 2017 16:40
MovementController.cs
using System;
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(CapsuleCollider))]
public class MovementController : MonoBehaviour {
[Serializable]
public enum Movement {
@Maxstupo
Maxstupo / MouseLook.cs
Last active September 8, 2017 09:44
Allows the mouse to rotate two game object transforms.
using System;
using UnityEngine;
/* ********************************************************************************************
* Program: MouseLook.cs
* Purpose: Allows the mouse to rotate two game object transforms.
* Date: 3/04/2017
* Author: Maxstupo
* ****************************************************************************************** */
public class MouseLook : MonoBehaviour {