Skip to content

Instantly share code, notes, and snippets.

@asufana
asufana / Java8 Stream, Optional, Either and Try.md
Last active November 24, 2021 05:54
Java8 Streamから学ぶOptionalモナドとEitherモナド。

Java8 Stream, Optional, Either and Try.

Java8 Stream の使い方を覚えたら、Optional や Either もすぐ使えるようになるよ!編

Stream

リスト要素の有無を意識せずに処理することができる

@tsubaki
tsubaki / LightmapPrefab.cs
Last active January 31, 2017 02:21
PrefabにLightmapを適応する
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class LightmapPrefab : MonoBehaviour {
[System.Serializable]
class LightmapParameter
{
public int lightmapIndex = -1;
@nkjzm
nkjzm / FixedScrollRect.cs
Last active January 31, 2019 03:20
uGUIで無限スクロールビューを一定間隔で止まるように拡張するスクリプト
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections;
public class FixedScrollRect : ScrollRect
{
private const float POWER = 10;
private InfiniteScroll _infinityScroll;
@benkulbertis
benkulbertis / cloudflare-update-record.sh
Last active February 25, 2025 10:56
Cloudflare API v4 Dynamic DNS Update in Bash
#!/bin/bash
# CHANGE THESE
auth_email="[email protected]"
auth_key="c2547eb745079dac9320b638f5e225cf483cc5cfdda41" # found in cloudflare account settings
zone_name="example.com"
record_name="www.example.com"
# MAYBE CHANGE THESE
ip=$(curl -s http://ipv4.icanhazip.com)
@tsubaki
tsubaki / GraphicCast.cs
Last active May 9, 2018 08:32
GraphicRaycasterの当たり判定だけを使う
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.UI;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.UI
{
@tsubaki
tsubaki / SortingLayer.cs
Last active May 20, 2016 06:38
SortingLayerを設定する。ShaderにTransparentとかParticle使っている場合はコレで描画順が制御出来る
/// Set Sorting Layer
/// Copyright (c) 2014 Tatsuhiko Yamamura
/// Released under the MIT license
// / http://opensource.org/licenses/mit-license.php
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
@uupaa
uupaa / Math.imul.md
Last active August 29, 2015 14:10
Math.imul

こちらは、shibukawa さんのエントリ へのアンサー・ソング的な何かです。

Math.imul を使うと、C言語のコードを原型を維持したまま JavaScript に変換することができます。
これにより、派生版の実装がだんだんC言語版から取り残されていく(Box2D的な残念な)現象を最小限にできるのではないでしょうか。

高速なHash関数 xxhash.c を JavaScript に変換した WMXXHash.js を例に説明するとこのようになります。

若干のコーディングスタイルの変化(JSHint対策)や、UINT32 な変数を5個作り出すために new Uint32Array(5) を使うというアイデアが入っていますが、変数名などは基本的にC言語のコードのままにしてあります。

int radio = 0;
bool node = false;
bool titleLeft = false;
bool titleMid = false;
bool titleRight = false;
void OnGUI()
{
@minazou67
minazou67 / java-se-0-note.md
Last active December 3, 2015 02:14
Notes the Java SE
@Flafla2
Flafla2 / Perlin_Tiled.cs
Last active September 18, 2025 15:11
A slightly modified implementation of Ken Perlin's improved noise that allows for tiling the noise arbitrarily.
public class Perlin {
public int repeat;
public Perlin(int repeat = -1) {
this.repeat = repeat;
}
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;