Skip to content

Instantly share code, notes, and snippets.

View tid-kijyun's full-sized avatar

Atsushi Kiwaki tid-kijyun

View GitHub Profile
@tid-kijyun
tid-kijyun / tally-counter.lua
Last active June 11, 2023 06:25
[OBS Script]Sets a text source to act as a tally counter when the source is active.
obs = obslua
source_name = ""
format_text = ""
start_number = 0
step_number = 0
now_count = 0
last_text = ""
activated = false
@tid-kijyun
tid-kijyun / CodePiece.swift
Created October 29, 2017 19:32
RxSwift + RxRealmで複数セクションに対応したDataSourceを作ってみたけどまだ欲しいものになってない感じ #CodePiece
public class Section: Object, RealmSectionModelType {
public typealias Item = RowItem
public let item = List<Item>()
@objc dynamic var title = ""
}
public class RowItem: Object {
@objc dynamic var title = ""
}
@tid-kijyun
tid-kijyun / gist:4c1b786061c1e8e8676078b44b2de98f
Last active January 27, 2017 08:45
byWordWrappingな文字列に必要な高さを求めてみる
func heightForStringDrawing2(myString: String, myFont: NSFont, myWidth: CGFloat) -> CGFloat {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineBreakMode = .byWordWrapping
let attribute: [String : Any] = [
NSFontAttributeName: myFont,
NSParagraphStyleAttributeName: paragraphStyle
]
let constraintsSize = CGSize(width: myWidth, height: CGFloat(FLT_MAX))
let textSize = NSString(string: myString).boundingRect(with: constraintsSize, options: .usesLineFragmentOrigin, attributes: attribute, context: nil)
return textSize.height
@tid-kijyun
tid-kijyun / file0.txt
Last active August 29, 2015 14:18
Genericクラスでデフォルト引数(enum)を持つメソッドの後に定義したメソッドはクラス内から見えなくなる ref: http://qiita.com/_tid_/items/77388352d30bb043315e
// Unityでエラーとなるコード(Ver4.6.3f1で確認 )
public enum EnumType {
Default,
TypeA,
}
public class Hoge<T> {
public void test() {
Found(); //!< OK
NotFound(); //!< error CS0103: The name 'NotFound' does not exist in the current context
@tid-kijyun
tid-kijyun / file0.txt
Last active August 29, 2015 14:17
uGUIのボタンにスクリプトからイベントを設定する方法 ref: http://qiita.com/_tid_/items/4d418e10bf74f7a5da94
// uGUIのボタンなどにイベントを設定するスクリプト例
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections.Generic;
public class HogeScript : MonoBehaviour {
void Start() {
var trigger = gameObject.AddComponent<EventTrigger>();
trigger.delegates = new List<EventTrigger.Entry>();
@tid-kijyun
tid-kijyun / HelloWorldScene.cpp
Created October 5, 2014 12:40
cocos2d-x 3.x : setup touch event
bool HelloWorld::init()
{
// ...
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchMoved, this);
listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
// ...
@tid-kijyun
tid-kijyun / file0.swift
Created July 9, 2014 16:57
横幅からWrappedなテキストが納まる領域の高さを求める方法 ref: http://qiita.com/_tid_/items/e6e959e4b82c7f478211
func heightForStringDrawing(myString: String, myFont: NSFont, myWidth: CGFloat) -> CGFloat
{
var textStorage = NSTextStorage(string: myString)
var textContainer = NSTextContainer(containerSize: NSMakeSize(myWidth, CGFloat(FLT_MAX)))
var layoutManager = NSLayoutManager()
layoutManager.addTextContainer(textContainer)
textStorage.addLayoutManager(layoutManager)
textStorage.addAttribute(NSFontAttributeName, value:myFont, range:NSMakeRange(0, textStorage.length));
textContainer.lineFragmentPadding = 0.0