Skip to content

Instantly share code, notes, and snippets.

View yuta0801's full-sized avatar

yuta yuta0801

View GitHub Profile
@yuta0801
yuta0801 / GetYouTubeLiveChat.md
Last active May 31, 2023 15:47
YouTubeLiveChatを取得する

YouTubeライブチャットを取得する

注意:ライブラリなどを使用すれば更にかんたんに安定に取得できる可能性がありますが、

ここではライブラリを使わずにAPIKEYだけで使えるAPIのみで取得することを優先しています

1, ライブIDを取得する

この工程は省略できますが、毎回IDを教えて上げる必要があります。

@yuta0801
yuta0801 / help.lua
Created March 29, 2018 13:40 — forked from NotSoSuper/help.lua
NotSoBot Help Documentation
Complete command list of NotSoBot <170903342199865344>:
Owner: NotSoSuper <130070621034905600>
Prefix: .
* = Not Required
^ = Bot Owner Only
^^ = Server Admin Only
"/'s" in commands show aliases for the command (Ex: ".reverse/r <text>" Command can be run with .reverse or .r)
<max_messages> = The number of messages to search through
<image> = The image URL, @discord_user, the users name, discord/custom emoji, or, nothing inputted which will search through 25 messages for embeds or attachments
<image-face> = Image requires a HUMAN FACE to be included
@yuta0801
yuta0801 / server.js
Created November 17, 2018 15:28
ファイル整理してたらNode.js始めたばかりの頃にリバースプロキシ風の処理を自作したコードが出てきて懐かしいので晒す
const app = require('http').createServer(handler)
const io = require('socket.io')(app)
const path = require('path')
const fs = require('fs')
const mime = require('mime-types')
io.sockets.on('connection', socket => {
socket.on('socket', data => {
console.log(data)
io.sockets.emit('socket',data)
@yuta0801
yuta0801 / alert.md
Last active April 12, 2019 08:18
JavaScript Alert Recursion with Goldbach's conjecture

加筆編集しより多くの人に理解できるようにしたものをQiitaに投稿しました。 こっちはリンク、リビジョン確認用に残しますが、これからの修正はQiitaメインになります。 alert無限ループは不正プログラムとして逮捕されるらしいので警察にゴールドバッハ予想を証明してもらおう - Qiita

これは何?

これは以下のツイートに触発されて作ったn回目のアラートダイアログで2n+2を二つの素数の和で表せるかを全探索して表せた場合もう一度アラートダイアログを表示するJavaScriptプログラムだよ

n回目のアラートダイアログで2n+2を二つの素数の和で表せるかを全探索して表せた場合もう一度アラートダイアログを表示するみたいなプログラムを書けば警察がゴールドバッハ解いてくれるのでは

— ほんまか? (@Kory__3) March 4, 2019

それぞれのファイルの説明

@yuta0801
yuta0801 / generatorify.js
Created March 23, 2019 10:09
Generatorify EventEmitter
// Referred to https://raw.githubusercontent.com/denoland/deno_std/v0.3.2/http/server.ts
function deferred() {
let resolve, reject
const promise = new Promise((res, rej) => {
resolve = res
reject = rej
})
return {
promise,
@yuta0801
yuta0801 / asyncTimerRecursiveFibo.js
Last active January 15, 2020 15:57
Fibonacci number implemented with recursive function async timer recursive function
// Utility function to make fake async processing
const delay = fn => new Promise(r => setTimeout(() => r(fn()), 100))
const isConstant = n => delay(() => n < 2)
const fibo = async n => {
if (await isConstant(n)) return n === 0 ? 0 : 1
const [prev1, prev2] = await Promise.all([fibo(n - 1), fibo(n - 2)])
return delay(() => prev1 + prev2)
}
@yuta0801
yuta0801 / e-typing.js
Created April 20, 2019 17:23
e-typingのお題をクリップボードにコピーするコード
const cp = copy
const observe = (target, callback) => {
const observer = new MutationObserver(records => {
records.forEach(record => {
if (!record.addedNodes[0]) return
callback(record, () => observer.disconnect())
})
})
observer.observe(target, { childList: true })
}
@yuta0801
yuta0801 / piping2sh
Created May 7, 2019 12:14
パイピングサーバーからコマンドを取得して実行するシェルスクリプト
#!/bin/bash -e
if [ $# -ne 1 ]; then
echo "引数(パス)が必要です。" 1>&2
exit 1
fi
CMD=$(curl -m 5 -sS "https://ppng.ml/$1")
read -p "$CMD を実行しますか? (y/N): " YN
const f1 = <T>(val: T) => val
const f2 = <T>(val: T) => () => val
const t1: 'foo' = f1('foo')
// const f1: <"foo">(val: "foo") => "foo"
const t2: 'foo' = f2('foo')()
// const f2: <string>(val: string) => () => string
// Type 'string' is not assignable to type '"foo"'. ts(2322)
@yuta0801
yuta0801 / index.js
Created August 25, 2019 08:59
RustよりJSが早かった時のソースコード
var addon = require('../native');
const factorial = (x) => {
let res = x;
let done = false;
while (!done) {
x = x - 1;
res = res * x;