Skip to content

Instantly share code, notes, and snippets.

@m039
m039 / Singleton.cs
Created August 3, 2023 00:12
Basic Unity singleton
public class Singleton<T> : MonoBehaviour where T : Singleton<T>
{
static public T s_Instance;
static public T Instance
{
get
{
if (s_Instance == null)
{
@m039
m039 / PixalizationRenderFeature.cs
Created August 16, 2021 19:43
Low-Res URP Feature
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class PixalizationRenderFeature : ScriptableRendererFeature
{
class PixalizationRenderPass : ScriptableRenderPass
{
PixalizationRenderFeature _parent;
@m039
m039 / BT.cs
Created August 11, 2019 16:46
The Behavior Tree source code file from Unity's 2D Game Kit project.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BTAI
{
public enum BTState
{
Failure,
Success,
@m039
m039 / Final.cs
Last active March 2, 2017 22:30
C# structs and classes as wrappers, performance benchmark
using System;
using System.Diagnostics;
namespace VoidSharedProject
{
// Results:
// 1: 00:00:47.3721840
// 2: 00:01:14.6771620
@m039
m039 / spacemacs-gyp-layer.el
Created February 14, 2017 15:22
Spacemacs gyp layer
;;; packages.el --- gyp layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Dmitry Mozgin <m039@Dmitrys-MBP>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
@m039
m039 / Bar.hpp
Last active February 14, 2017 09:13
Issue when using empty namespace in CppSharp
#pragma once
#include "IBar.hpp"
// Bar hosts IBar
class Bar {
public:
IBar *impl;
@m039
m039 / 37.1.rkt
Last active January 28, 2017 12:43
Exercise 37.1 form the HtDPv1 book. A little bit overdone though.
#lang racket/gui
;;; Exercise 37.1 from the HtDP book. A little bit overdone.
;;;
;;; GUI related functions
;;;
(define (create-frame title size draw-callback on-event-handler)
(define custom-canvas%
@m039
m039 / TouchController.cs
Last active January 25, 2017 20:11
Very easy implementation to handle basic horizontal and vertical swipes for Unity on mobile devices
/// <summary>
/// TouchController allows you to handle basic swipes (left, right, top, bottom) on mobile device.
///
/// Usage: extend this class and don't forget to call Update in MonoBehaviour.Update
/// <summary>
public abstract class TouchController {
private readonly float _swipeThreshold;
private Vector2 _firstPosition;
@m039
m039 / gist:8384823
Created January 12, 2014 13:55
android stuff
# clean application data
adb shell pm clear com.android.browser
;; Playing with racket
(require net/url)
(require json)
(require rnrs/io/ports-6)
(define link "http://graph.facebook.com/")
(define (get-username id)
(let ((ht (call-with-port (get-pure-port (string->url (string-append link id)))
(lambda (p)