Skip to content

Instantly share code, notes, and snippets.

{
"data": {
"type": "properties",
"collection": [
{
"objectid": 2,
"name": "1FL",
"externalId": "e3e052f9-0156-11d5-9301-0000863f27ad-00000137",
"properties": {
"拘束": {
@shogo-hab
shogo-hab / closure_memo.js
Last active July 13, 2021 07:36
useStateっぽい動きをするクロージャ
// stateを保持するためのクロージャ
let createClosure = function(){
let state;
// クロージャを参照可能な関数を組み立てて返却する
return function useState(initialValue){
// クロージャのstateが初期化されてなければinitialValueで初期化
if(!state){
state = initialValue;
}
@shogo-hab
shogo-hab / 00.M1_MBA
Last active December 27, 2020 08:46
nodeのビルド時間
{
platform: {
cpu: 'Apple processor',
coreNum: 8,
totalMemory: 8589934592,
nodeVersion: 'v15.5.0',
os: 'darwin, 20.1.0'
},
result: {
typescript: [ 2394, 2405, 2396, 2391 ],
@shogo-hab
shogo-hab / 00_snipet-01.js
Last active August 23, 2020 02:22
Forge + Node.jsのスニペット
// Forgeから取得したJSONをNodeでファミリごとに割り当て済みのマテリアルをリスト化するsnipet
// ForgeのDerivative APIで取得できるpropertiesとtreeのJSON
const t= require("tree");
const p = require("properties");
var list = t.objects.filter((f)=>{
// インスタンスもってるファミリだけにフィルタリング
const types = f.objects;
return types.every((type)=>{ return type.objects })
@shogo-hab
shogo-hab / pixelStreamingHandShake.js
Last active August 12, 2020 06:06
PixelStreamingをVanilla JSでハンドシェイクしたメモ
// なにこれ?
// -> ReactHooksで実装したPixelSteamingのハンドシェイクをコンソールにペタペタしたら動くようにしてみた
// 0. ゴールと前提
// ゴール:
// - WebSocket(SignalingServer)とWebRTC APIを介して経路情報を交換してPixelStreaming PluginとのP2Pを確立する
// - WebRTCのvideoストリームを取得する
// - WebRTCのデータチャネルを繋いでブラウザのアクションとPixelStreamingからのデータを受け取れるようにする
// - videoストリームが取得できたらDOMのsrcObjectに渡してブラウザでストリームを表示する
// 前提:
@shogo-hab
shogo-hab / Start_Local_WithGoogleSTUN.ps1
Last active August 12, 2020 05:43
ローカル環境からGoogleのSTUNでNAT越えするためのPixelStreaming起動スクリプト
npm install
$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:stun.l.google.com:19302\""]}] }"
$ProcessExe = "node.exe"
$Arguments = @("cirrus", "--peerConnectionOptions=""$peerConnectionOptions""")
# Add arguments passed to script to Arguments for executable
$Arguments += $args
Write-Output "Running: $ProcessExe $Arguments"
Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -Wait -NoNewWindow
@shogo-hab
shogo-hab / App.jsx
Last active August 7, 2020 09:19
Pixel Streaming用のcustom hooks
import React, { useState, useEffect, useRef } from "react";
import logo from "./logo.svg";
import "./App.css";
import usePixelStreaming from "./usePixelStreaming";
function App() {
const videoElement = useRef(null);
const { peer, dataChannel, videoStream } = usePixelStreaming("ws://YOUR_PIXEL_STREAMING_HOST");
@shogo-hab
shogo-hab / cloudSettings
Last active December 27, 2020 07:55
VSCode Setting sync
{"lastUpload":"2020-11-05T02:03:37.362Z","extensionVersion":"v3.4.3"}