Skip to content

Instantly share code, notes, and snippets.

@su10
su10 / Canvasタグで作るお絵かきツール
Created May 20, 2012 03:30
自作のGreasemonkeyスクリプト
// ==UserScript==
// @name Canvasタグで作るお絵かきツール
// @namespace su10
// @description せつめいぶんだよ
// @include http://*
// @version 1.0.0
// ==/UserScript==
var body = document.getElementsByTagName("body")[0];
body_style = document.defaultView.getComputedStyle(body, "");
def hash_for_includes_all_masters(recursive=true, all_associations=[])
all_associations << self.to_s
result_arr = []
self.reflect_on_all_associations.each do |model|
association_name = model.name
class_name = model.class_name
next if all_associations.include?(class_name)
next unless class_name.include?('Master')
next if model.options.has_key?(:polymorphic)
@su10
su10 / promise_snipet
Created November 2, 2014 09:46
promise-as3のPromise#when実装
public function when( ...args ):Promise {
if( args.length == 1 && args[0] is Array ) {
args = args[0];
}
// 引数が0個ならreject
if( args.length == 0 ) {
return this.then(
function( value:* ):void {
Deferred.reject('arguments must not be empty.');
@su10
su10 / Drag.cs
Created April 10, 2017 07:54
【Unity】UniRxを使ったドラッグ移動のサンプル【UniRx】 ref: http://qiita.com/su10/items/ae3fd460a5762438a9d1
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UniRx;
using UniRx.Triggers;
public class Drag : MonoBehaviour
{
public RectTransform target;
public bool horizontal = true;
@su10
su10 / WaitForObservable.cs
Last active July 6, 2017 14:40
【Unity】Subscribeしなくても動作してかつSubscribeすることで結果も必ず受け取れるストリームを作る方法【UniRx】 ref: http://qiita.com/su10/items/caffe7877adfab54263c
using System;
using UnityEngine;
using UniRx;
public class WaitForObservable : MonoBehaviour
{
[SerializeField]
private Window _window;
void Start()
@su10
su10 / DataBinding1.cs
Last active June 15, 2017 11:03
UniRx入門 ~ データバインディングとUnityイベント関数の購読 ~ ref: http://qiita.com/su10/items/6d7fd792d4b553454a4f
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
public class DataBindingSample1 : MonoBehaviour
{
// NOTE: newするときに初期値を与えることが可能
public ReactiveProperty<int> _intProperty = new ReactiveProperty<int>(1);
@su10
su10 / PhotonExtensions.cs
Created May 13, 2017 03:32
【Unity】PhotonNetwork.OnEventCallをAsObservableにする【PhotonRx】 ref: http://qiita.com/su10/items/1b7a792ce9bd90debdb0
namespace UniRx
{
public static class PhotonExtensions
{
public static IObservable<Tuple<byte, object, int>> AsObservable(this PhotonNetwork.EventCallback eventCallback)
{
return Observable.FromEvent<PhotonNetwork.EventCallback, Tuple<byte, object, int>>(
h => (x, y, z) => h(Tuple.Create(x, y, z)),
h => PhotonNetwork.OnEventCall += h,
h => PhotonNetwork.OnEventCall -= h
@su10
su10 / NetworkSpawner.cs
Last active January 26, 2022 07:26
Photonでオブジェクトをスポーンする方法の調査およびIPunPrefabPoolとUniRx.Toolkit.ObjectPoolを使ったオブジェクトプールのサンプル ref: http://qiita.com/su10/items/4bae56bc814c4e6a2bc0
using Photon;
using PhotonRx;
using System.Linq;
using UniRx;
using UniRx.Toolkit;
using UniRx.Triggers;
using UnityEngine;
namespace Jagapippi.Network
{
@su10
su10 / ObservableSocialWorker.cs
Last active July 6, 2017 14:27
【Unity】SocialWorkerをObservableに使うラッパークラスを書いた【UniRx】 ref: http://qiita.com/su10/items/d550d6c31306e8720d03
using SWorker;
using UniRx;
namespace Jagapippi.Social
{
public static class ObservableSocialWorker
{
public static IObservable<Unit> PostTwitterAsync(string message, string url, string imagePath)
{
return Observable.Create<Unit>(observer =>
@su10
su10 / CaptureScreenshotFromEditor.cs
Last active November 13, 2017 10:04
【Unity】指定した解像度のスクリーンショットを実機なし・エディタだけで撮る方法【2017.1対応】 ref: https://qiita.com/su10/items/a8f3f825155835de3d2a
using System.Collections;
using UniRx;
using UnityEditor;
using UnityEngine;
/// <summary>
/// Unityエディタ上からGameビューのスクリーンショットを撮るEditor拡張
/// </summary>
public class CaptureScreenshotFromEditor : Editor
{