Skip to content

Instantly share code, notes, and snippets.

View n-yoda's full-sized avatar
🏠
Working from home

Nobuki Yoda n-yoda

🏠
Working from home
View GitHub Profile
using UnityEngine;
using UnityEditor;
using System.IO;
public class BakeRenderTexture
{
[MenuItem("Assets/Bake RenderTexture to PNG")]
static void Bake()
{
// Get selected RenderTexture
@n-yoda
n-yoda / glyph2dot.c
Last active September 20, 2015 06:34
FreeType example. Load font file and export a specified glyph shape as a graphviz dot file.
/*
gcc -I/usr/local/include/freetype2 -lfreetype glyph2dot.c -o glyph2dot
./glyph2dot hoge.ttf 0 A | dot -Kfdp -n -Tpng -o A.png
*/
#include <stdio.h>
#include <stdlib.h>
#include <ft2build.h>
#include FT_FREETYPE_H
@n-yoda
n-yoda / opt9p.sh
Last active August 29, 2015 14:18
Optimize 9-patch images by shrinking inner region.
#!/bin/bash
#
# opt9p.sh
# Optimize 9-patch images by shrinking inner region.
# Copyright 2015 Nobuki Yoda.
#
# Usage:
# L=10 W=1 R=10 T=10 H=1 B=10 ./opt9p in.png out.png
#
# Simple Usage:
@n-yoda
n-yoda / twitter-maasai.js
Last active August 29, 2015 14:18
Twitterの上にスワイプすると飛んでいくマサイ族をブラウザで楽しむブックマークレット
/*
bookmarkletify twitter-maasai.js
javascript:(function(){;var%20x=$(%22.media-image%22);var%20y=x.clone().appendTo(%22body%22).css(%7Bposition:%22absolute%22,top:x.offset().top,left:x.offset().left,zIndex:5e3%7D).animate(%7Btop:$(window).scrollTop()-x.height()%7D,300,%22swing%22,function()%7By.remove()%7D);x.css(%7Bopacity:0%7D).delay(1e3).animate(%7Bopacity:1%7D);})()
*/
var x = $('.media-image');
var y = x.clone().appendTo('body')
.css({position: 'absolute', top: x.offset().top, left: x.offset().left, zIndex: 5000})
.animate({top: $(window).scrollTop() - x.height()}, 300, 'swing', function(){y.remove()});
x.css({opacity:0}).delay(800).animate({opacity:1});
@n-yoda
n-yoda / FindStap.cs
Created June 4, 2014 17:34
STAP細胞
using System;
using System.Collections.Generic;
using System.Linq;
public class FindStap
{
public static void Main()
{
var rand = new Random();
@n-yoda
n-yoda / ut2python.js
Created May 13, 2014 06:22
東京大学( http://www.u-tokyo.ac.jp/ )のロゴをPython( https://www.python.org/ )のロゴに入れ替えるブックマークレット。
javascript:$("#header_logo img").before('<div style="width:55px;overflow:hidden;float:left"><img src="https://www.python.org/static/img/python-logo.png" height="60"></div>').wrap('<div style="width:145px;overflow:hidden"></div>').css('position', 'relative').css('left', '-55px')
@n-yoda
n-yoda / SerializedObjectEditor.cs
Last active June 8, 2018 00:58
Unityの任意のアセットを編集するエディタスクリプト http://ny.hateblo.jp/entry/2014/03/23/051546
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// 「Window/SerializedObject Editor」で起動。
/// 選択中のObjectと関連ObjectからSerializedObjectを作ってPropertyを全て表示する。
/// </summary>
public class SerializedObjectEditor : EditorWindow
@n-yoda
n-yoda / TextureGenerator.cs
Last active July 15, 2016 16:35
[UNITY] Generate texture from a function : UV => Color.
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
public static class TextureGenerator
{
static string GetNewPath(string name)
{
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
@n-yoda
n-yoda / TouchTheNumberLINQ.cs
Last active December 20, 2015 01:19
Unityで動くタッチザナンバーをLINQを乱用して書いてみた
using UnityEngine;
using System.Collections;
using System.Linq;
// タッチザナンバーをLINQを乱用して書いてみた.
// 数字が0から始まることに注意.
public class TouchTheNumberLINQ : MonoBehaviour
{
public int len = 5; //横方向のマス数=縦方向のマス数