Skip to content

Instantly share code, notes, and snippets.

View sujoyu's full-sized avatar

すじょうゆ sujoyu

View GitHub Profile
@sujoyu
sujoyu / balloon-annotation-sample.html
Last active August 29, 2015 14:17
Tooltip(balloon annotation) implemented with only CSS3.
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://gist.githubusercontent.com/sujoyu/d3a187ee3b30a2f2009f/raw/5a1e111f77ae49c8173fc8574738eb9e8c3cd312/balloon-annotation.css">
</head>
<body>
<br />
<div class="balloon-annotation">
annotation legend.
<p class="balloon-annotation-body">annotation body! FOOOOOOOO!!</p>
</div>
@sujoyu
sujoyu / Closer.cs
Last active August 3, 2016 04:55
A Simple unity script for modal dialogs on uGUI. When click outside the modal, close it.
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using System.Linq;
public class Closer : MonoBehaviour, IPointerClickHandler {
public int ancestorLevel = 0;
public void OnPointerClick(PointerEventData data) {
@sujoyu
sujoyu / EventManager.cs
Last active August 4, 2016 10:59
A simple weak event pattern by C# for Game.
using System;
using System.Collections.Generic;
using System.Linq;
// Static singleton class.
// There is no necessary to access this class directly.
public class EventManager {
private static Dictionary<GameEvent, List<WeakReference>> listeners =
new Dictionary<GameEvent, List<WeakReference>>();
@sujoyu
sujoyu / EnumLikeJava.cs
Last active October 12, 2022 17:03
C# enum like Java sample.
using System;
public class EnumLikeJava {
public static readonly EnumLikeJava enum1 = new EnumLikeJava("enum1", (s) => s + "foo");
public static readonly EnumLikeJava enum2 = new EnumLikeJava("enum2", (s) => s + "bar");
public static readonly EnumLikeJava enum3 = new EnumLikeJava("enum3", (s) => s + "baz");
public readonly string Field;
public readonly Func<string, string> _method;
@sujoyu
sujoyu / Main.scala
Last active September 9, 2016 05:59
数字の書いてあるN枚のカードから、足してAになる組み合わせの数をかぞえる
object Main {
def main(args:Array[String]) = {
val sc = new java.util.Scanner(System.in)
val n, a = sc.nextInt
val x = List.fill(n)(sc.nextInt)
val nx = (a :: x).max * n
val dpMemo = collection.mutable.ArrayBuffer.fill(n + 1, n + 1, nx + 1)(-1L)
def dp(j: Int, k: Int, s: Int): Long = {
@sujoyu
sujoyu / Main.scala
Last active July 3, 2017 09:46
Scala parser combinator sample like HTML tag.
import scala.util.parsing.combinator._
import scala.language.postfixOps
object Main {
def main(args:Array[String]) = {
val sc = new java.util.Scanner(System.in)
val input = collection.mutable.ListBuffer[String]()
while(sc.hasNextLine) {
input += sc.nextLine
@sujoyu
sujoyu / .zshrc
Last active September 22, 2016 10:59
Windows path to WSL(Bash on Ubuntu on Windows10) path convertor for cbwin( https://github.com/xilun/cbwin ) written with zsh.
WIN_USER=john
LINUX_ROOT="C:\\Users\\$WIN_USER\\AppData\\Local\\lxss\\"
alias wcmd=to_win_path
to_win_path() {
join_by() { local IFS="$1"; shift; echo "$*"; }
local IFS narg arg dirnames
narg=()
@sujoyu
sujoyu / reader.js
Last active September 23, 2016 08:23
javascript sequential stdin reader.
var reader = new Reader(10);
var input = {};
reader.read(function(line) {
var vars = line.split(' ')
input.m = parseInt(vars[0]);
input.n = parseInt(vars[1]);
}).then(reader.read(function(line) {
input.o = line;
})).then(function() {
input.xs = [];
@sujoyu
sujoyu / for-ios10.js
Created October 8, 2016 15:18
Google Maps Scripts API bug fix code on iOS 10.
(function() {
function ios_ver (){
var ios_ua = navigator.userAgent;
if( ios_ua.indexOf("iPhone") > 0 ) {
ios_ua.match(/iPhone OS (\w+)/g);
var version = RegExp.$1.split("_")[0];
return version;
}
}
if (ios_ver() === '10') {
@sujoyu
sujoyu / WorkerMain.scala
Last active December 1, 2016 09:47 — forked from ochrons/WorkerMain.scala
Web Worker PoC in Scala.js
package poc
import org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
@js.native
object WorkerGlobal extends js.GlobalScope {
def addEventListener(`type`: String, f: js.Function): Unit = js.native