Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block onionmk2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
onionmk2 /
Last active Jan 5, 2018 — forked from athiakos/cuda cheat sheet
cuda のid計算がよくわからないので、まとめてみる。
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
namespace comment_thread_id
blockIdx.x == n
blockIdx.y == 1
blockIdx.z == 1
onionmk2 / gist:a2c26752975a2509dc69cf564f87e709
Created Apr 3, 2017 — forked from LearnCocos2D/gist:77f0ced228292676689f
Overview of Entity Component System (ECS) variations with pseudo-code
View gist:a2c26752975a2509dc69cf564f87e709

For background and further references see: Entity Component Systems on Wikipedia

ECS by Scott Bilas (GDC 2002)

  • entity = class: no logic + no data OR at most small set of frequently used data (ie position)
  • component = class: logic + data
foreach entity in allEntities do
    foreach component in entity.components do
onionmk2 / gist:97a593048f4efe1fcd48e3760bb7b73e
Created Feb 16, 2017 — forked from tany3/gist:2d032cbbbd9db04b976d
重複処理 IEnumerableをそのまま使い回さない - Possible multiple enumeration of IEnumerable
View gist:97a593048f4efe1fcd48e3760bb7b73e


Assuming that GetNames() returns an IEnumerable, we are, effectively, doing extra work by enumerating this collection twice in the two foreach statements. If GetNames() results in a database query, you end up doing that query twice, while both times getting the same data.


参考:LINQ クエリの概要 (C#)

onionmk2 /
Created Feb 5, 2017 — forked from Ashwinning/
A copy of the post on Singletons in Unity/C# as it appeared on


Original post by David Laskey on UnityPatterns

As you develop in Unity, you’ll often find that it’s handy to have just single instances of certain objects. For example, let’s say we have a single GameObject, “MusicManager”, that’s in charge of our music. It might look like this:

using UnityEngine;
You can’t perform that action at this time.