Skip to content

Instantly share code, notes, and snippets.

onionmk2

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
onionmk2 / get_global_id.cu
Last active Jan 5, 2018 — forked from athiakos/cuda cheat sheet
cuda のid計算がよくわからないので、まとめてみる。
View get_global_id.cu
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
namespace comment_thread_id
{
/*
blockIdx.x == n
blockIdx.y == 1
blockIdx.z == 1
@onionmk2
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->Components->Update
  • 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
onionmk2 / gist:97a593048f4efe1fcd48e3760bb7b73e
Created Feb 16, 2017 — forked from tany3/gist:2d032cbbbd9db04b976d
重複処理 IEnumerableをそのまま使い回さない - Possible multiple enumeration of IEnumerable
View gist:97a593048f4efe1fcd48e3760bb7b73e

IEnumerableをそのまま使うと、使う度に毎回変換される。遅延実行。 http://confluence.jetbrains.com/display/ReSharper/Possible+multiple+enumeration+of+IEnumerable

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.

ということで、特に複数回使う場合など適宜ToList()やToArray()しておく。

参考:LINQ クエリの概要 (C#) http://msdn.microsoft.com/ja-jp/library/bb397906.aspx

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

Singletons

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.