Skip to content

Instantly share code, notes, and snippets.

@pentamania
pentamania / isPortTaken.mjs
Last active December 31, 2021 03:43 — forked from timoxley/isPortTaken.js
check if a port is being used with nodejs
import { createServer } from "net";
/**
* check if a port is being used (es2015+ ver)
* @param port
* @returns {Promise<boolean>}
*/
export function isPortTaken(port) {
return new Promise((resolve, reject) => {
const tester = createServer()
@pentamania
pentamania / ts-all-props-union-type.md
Last active August 26, 2021 04:48
Typescript classの全プロパティ(メソッド)名列挙型を生成するUtility Type
class Foo {
  private x: number = 0; 
  
  getX() {
   return this.x;
  }
  
 get xPlusOne() {
@pentamania
pentamania / extendPhinaEsModule.ts
Last active June 27, 2021 03:41
typescriptに怒られない形でphina-esmの拡張を行う方法(仮)
import { Object2D } from "phina.js";
// 拡張宣言部分: 拡張したいクラス型定義へのパス
declare module "phina.js/types/app/object2d" {
// プロトタイプ拡張する場合
export interface Object2D {
/**
* [ここに詳細]
*/
@pentamania
pentamania / babel-polyfill-notes.md
Last active July 5, 2021 13:51
babel polyfillについてのメモ(ライブラリ開発者向け)

Symbolなど、IE11などの古いブラウザが対応していない新しめの機能を使うとき、babel公式では二つのpolyfill方法を用意している

1. 一般的: polyfill系ライブラリを直import

import "core-js/stable";
import "regenerator-runtime/runtime";

core-jsはECMAScript機能を、

@pentamania
pentamania / youtube-embeded-play-error.md
Last active January 11, 2020 01:47
ローカルサーバーでyoutube iframe埋め込み動画が再生できないとき
@pentamania
pentamania / node-fs-extra_memo.md
Created December 14, 2019 08:59
たまに使うnode-fs-extraの備忘録
@pentamania
pentamania / js-generator-memo.md
Last active December 14, 2019 09:10
javascript generatorメモ

要訳

  • generator関数(*function)を実行するとgeneratorオブジェクト(以下genobj)を返す
  • json(配列)を使った応用ではyield*とfor-ofを使う

まずはgenerator関数の定義

// genobjを返す
var hoge = function*() {
  console.log('run hoge');
@pentamania
pentamania / blender-vrc-3d-modeling-process.md
Last active May 16, 2020 18:30
blenderで3DモデリングしてVRchat(quest)にアップロードするワークフロー

バージョン

  • blender 2.8
  • unity 2017.4.28f1
  • VRCSDK 2019.09.18.12.05

モデリング編

全般

  • サイズを確認しておく(でかいままにしておくと後々面倒)
  • 方向も確認しておく(特にx軸が→を指してる方向が正面になることを確認) ミラーや対称化系の処理でつまづくため。(修正は可能だが原因に気づきにくい)
@pentamania
pentamania / convertToESclass.js
Last active August 11, 2019 05:52
phina class to ES2015 class
/**
* phina-classを pure JS class(ES2015class)に変換
* @see https://qiita.com/Negiwine_jp/items/512248cce5d9274cbb83
* @param {phinaclass} phinaClass [description]
* @return {function}
*/
export function phinaClassConvert(phinaClass) {
const creator = function(){
phinaClass.prototype.init.apply(this, arguments)
}
@pentamania
pentamania / threejs-memo.md
Created May 16, 2019 15:26
three.js memo

loaderの読み込み方

  • 公式のパッケージ内にexample/js/loaderがあるのでそこから適当なローダーを読み込む
<script src='node_modules/three/build/three.js'></script>
<script src="node_modules/three/examples/js/loaders/GLTFLoader.js"></script>
  • loaderモジュールはnpmにもあるが、nodeにしか対応してないのでCDN読み込みではエラーになる
  • orbit-controlなども同様