Skip to content

Instantly share code, notes, and snippets.

@W4RH4WK
W4RH4WK / FSM.cs
Last active May 14, 2024 16:29
C# Generic Finite State Machine
using System;
using System.Collections.Generic;
using System.Reflection;
namespace GenericFSM {
public class FSM<T> where T : struct, IConvertible {
public T State { get; private set; }
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
namespace Cluster {
public class CollisionCall : MonoBehaviour {
public LayerMask layerMask = -1;
@KeyMaster-
KeyMaster- / spriteGlitch.shader
Last active May 20, 2024 14:58
A glitch effect shader for Sprites in Unity3D
//Copyright (c) 2014 Tilman Schmidt (@KeyMaster_)
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in
@stavrossk
stavrossk / Import CSV file using PDO.php
Created May 11, 2014 13:00
Import a CSV file into a MySQL database using PHP PDO.
<?php
$databasehost = "localhost";
$databasename = "test";
$databasetable = "sample";
$databaseusername="test";
$databasepassword = "";
@r-lyeh-archived
r-lyeh-archived / compo.cpp
Last active December 9, 2019 06:28
Component-entity system in 16 lines of C++11. extract from kult engine (https://github.com/r-lyeh/kult)
#include <map> // Component-entity system in 16 lines of C++11. 2013 rlyeh, MIT licensed
#include <set> // Code fragment from kult engine - https://github.com/r-lyeh/kult
enum {JOIN,MERGE,EXCLUDE};using set=std::set<unsigned>;template<typename T> set&system(){
static set entities;return entities;}template<typename T,int MODE>set subsystem(const set
&B){set newset;const set&A=system<T>();if(MODE==MERGE){newset=B;for(auto&id:A)newset.ins\
ert(id);}else if(MODE==EXCLUDE){newset=B;for(auto&id:A)newset.erase(id);}else if(A.size()
<B.size()){for(auto&id:A)if(B.find(id)!=B.end())newset.insert(id);}else{for(auto&id:B)if(
A.find(id)!=A.end())newset.insert(id);}return newset;}template<typename T>std::map<unsig\
ned,T>&components(){static std::map<unsigned,T>objects;return objects;}template<typename\
T>bool has(unsigned id){return components<T>().find(id)!=components<T>().end();}templat\
@timothyandrew
timothyandrew / README.md
Last active December 16, 2023 17:05
Set up a seedbox (on DigitalOcean – Ubuntu) really quick

Introduction

  • This script lets you set up and use a temporary DigitalOcean droplet to download torrent files.
  • Once downloaded, they can be streamed down to your local machine.
  • This uses transmission-cli for the torrent client, and nginx to serve files.

Setup on Local Machine

  • This assumes that you have a DigitalOcean account and tugboat set up, as well as seedbox-setup.sh present in the current directory.
@amcgregor
amcgregor / fc-comms.rest
Last active December 14, 2015 04:58
A general overview of fleet communication phrases and best practices.

EVE's golden rule: Don't fly anything you can't afford to lose.

BNI's corollary: Anything you undock will be lost.

General

Listen to your FC. Do not talk over your FC. The exception to the latter is to scream bloody murder if something unexpected happens tactically and no-one else seemed to notice. (Fleet survival trumps radio politeness.) Add your FC to your fleet watch list. Add anyone else your FC recommends to your watch list. Keep chatter to the fleet text channel, and even then you should be too busy when shit gets real to chatter there, either. Nobody cares if you still need to load ammunition, nobody cares for your inane chattering.

You add people in your fleet to the watch list by right-clicking them in the fleet member list or a chat channel list and selecting Add to Watch List from the menu. (It may be under the Fleet sub-menu depending on where you're selecting their name from.)

@pixelrevision
pixelrevision / PixelPerfectCam.cs
Last active January 26, 2024 05:23
Script for unity to create a pixel locked orthogonal camera
using UnityEngine;
/**
* A camera to help with Orthagonal mode when you need it to lock to pixels. Desiged to be used on android and retina devices.
*/
public class PixelPerfectCam : MonoBehaviour {
/**
* The target size of the view port.
*/
public Vector2 targetViewportSizeInPixels = new Vector2(480.0f, 320.0f);
/**
@kizzx2
kizzx2 / fun.cpp
Created January 11, 2012 14:29
Illustrative C++ Lua binding example/tutorial
// fun.cpp
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <iostream>