Skip to content

Instantly share code, notes, and snippets.

View if1live's full-sized avatar
💭
I may be slow to respond.

byunghoo.yu if1live

💭
I may be slow to respond.
View GitHub Profile
@if1live
if1live / override_fetch.ts
Created January 8, 2024 12:59
override globalThis.fetch
// https://corsproxy.io/
const fetch_base = globalThis.fetch;
const fetch_next: typeof fetch_base = async (url, init) => {
if (typeof url === "string") {
const urlObj = new URL(url);
if (urlObj.hostname === "www.youtube.com") {
const proxyUrl = `https://corsproxy.io/?${encodeURIComponent(url)}`;
return await fetch_base(proxyUrl, init);
}
}
@if1live
if1live / pufferpanel_api.json
Created August 22, 2023 01:41
PufferPanel API
{
"schemes": [],
"swagger": "2.0",
"info": {
"description": "PufferPanel API interface for both the panel and daemon. Endpoints starting with /daemon or /proxy are for nodes.",
"title": "PufferPanel API",
"contact": {
"name": "PufferPanel",
"url": "https://pufferpanel.com"
@if1live
if1live / main.ts
Last active January 17, 2022 16:14
https://www.acmicpc.net/ typescript + windows + powershell template
import fs = require('fs')
function read_stdin(): string {
return fs.readFileSync(0).toString();
}
const chunk = read_stdin();
const numbers = chunk.split('\n')[0].split(' ').map(x => parseInt(x, 10));
const [a, b] = numbers;
const c = a + b;
process.stdout.write(c.toString());
@if1live
if1live / index.ts
Created July 18, 2020 17:38
API spec based api server/client library
import yup = require('yup');
import express from 'express';
import fetch, { Response } from 'node-fetch';
type Method = 'get' | 'post' | 'delete' | 'put';
interface Api<Req, Resp> {
name: string;
method: Method;
// url = resource + page
@if1live
if1live / index.ts
Last active July 15, 2020 14:36
generic based rosie constructor
import { Factory } from 'rosie';
import { NonFunctionKeys } from 'utility-types';
// maybe typeorm entity
class Entity {
constructor() {
this.a = 0;
this.b = null;
}
public a: number;
@if1live
if1live / cls-hooked-express-logging.js
Created July 11, 2020 04:28
cls-hooked + express + console.info()
/**
* test
* curl "http://127.0.0.1:3000/?id=1" & curl "http://127.0.0.1:3000/?id=2"
*/
const express = require('express');
const delay = require('delay');
const { getNamespace, createNamespace } = require('cls-hooked');
const NSID = 'writer';
@if1live
if1live / httpclient_unity_sample.cs
Created January 15, 2019 02:27
C# HttpClient + Unity + GET + json body
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
using System.Net.Http;
using System.Net;
@if1live
if1live / httpclient_sample.cs
Created January 15, 2019 02:04
c# HttpClient + GET + json body
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
namespace httpclient
/*
오늘의 코딩 퀴즈
숫자를 기수로 변환하기
1 => 일
73 => 칠십삼
598 => 오백구십팔
1920 => 일천구백이십
SHOW VARIABLES LIKE '%time_zone%'