Skip to content

Instantly share code, notes, and snippets.

View sassembla's full-sized avatar
😍
be gentle.

Toru sassembla

😍
be gentle.
View GitHub Profile
-- get identity of game from url. e.g. http://somewhere/game_key -> game_key
local identity = string.gsub (ngx.var.uri, "/", "")
-- generate pub-sub key from url.
IDENTIFIER_CENTRAL = identity .. "_pub"
IDENTIFIER_CLIENT = identity .. "_sub"
STATE_CONNECT = 1
STATE_MESSAGE = 2
-- get identity of game from url. e.g. http://somewhere/game_key -> game_key
local identity = string.gsub (ngx.var.uri, "/", "")
-- generate identity of queue for target context.
IDENTIFIER_CONTEXT = identity .. "_context"
-- identifier-client = UUID. e.g. AD112CD4-3A23-4E49-B562-E07A360DD836 len is 36.
HEADER_STRING = 's'
local gameKey = "test"
local identity = string.gsub (ngx.var.uri, "/", "") --replace /wildcard_sample* to wildcard_sample*
IDENTIFIER_CENTRAL = identity .. "_pub"
IDENTIFIER_CLIENT = identity .. "_sub"
STATE_CONNECT = "connect"
-- Disque client for lua.
local sub = string.sub
local byte = string.byte
local tcp = ngx.socket.tcp
local concat = table.concat
local null = ngx.null
local pairs = pairs
local unpack = unpack
local setmetatable = setmetatable
@sassembla
sassembla / context.lua
Created March 8, 2015 09:33
nginx + lua で複数クライアント接続での合同contextみたいなやつ
--[[]
ゲームとか書けるところ。あとコンテキストの名の通り、データベースに依存せずにパラメータとか持てるぞ。
]]
local M = {}
function M.onConnect(from, publish)
ngx.log(ngx.ERR, "connect from:", from)
end
@sassembla
sassembla / LogWriter.cs
Created February 25, 2015 14:35
LogWriter
using UnityDebug = UnityEngine;
using System.IO;
using System.Text;
using System.Diagnostics;
public class LogWriter {
private static string targetPath = string.Empty;
public static void StartTransLogging (string path) {
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
/**
仮。もっと小さくしたい。
ネームスペースごとに、扱える数が異なる。
*/
@sassembla
sassembla / TimeAssertForUnity
Last active August 29, 2015 14:02
TimeAssert for Unity
/*
example
"2014/06/23 3:05:34".TimeAssert(30, "time over!");
*/
using System;
using System.Globalization;
using UnityEngine;
static class Assertions {
@sassembla
sassembla / Simple Assertion in Unity
Last active August 29, 2015 14:02
Simple Assertion in Unity.
static class Assertions {
/**
assert which extends bool.
usage:
(0 < transform.position.y).Assert("fall in negative.");
*/
public static void Assert (this bool condition, string reason) {
if (condition) return;
// shader error & warning
{
// Shader error in 'Custom/TestShader': Parse error: syntax error at line 9
"Shader error in [']Custom/(.*)[']: (.*) at line ([0-9].*)": {
"injects": {
"groups[0]": "name",
"groups[1]": "message",
"groups[2]": "line"
},
"selectors": [