Skip to content

Instantly share code, notes, and snippets.

View flashlin's full-sized avatar

Mr.Flash flashlin

  • Taiwan
View GitHub Profile
@flashlin
flashlin / ReadMe.md
Created July 1, 2021 14:30
RequestProxy

創建一個新的 API 項目。在項目的 Startup 類的 ConfigureServices 方法中,使用AddCors擴展方法向 CORS 選項添加策略。

services.AddCors(options => { options.AddPolicy( "Open", builder => builder.AllowAnyOrigin().AllowAnyHeader()); });

CorsPolicyBuilder 對像有一組可鏈接的方法,它們為允許的來源、標題和方法設置各種規則。在這裡,我剛剛說過,我將接受任何來源和任何標題。請注意,這僅用於演示目的:接受任何來源並不真正安全,因為它允許任何站點連接到代理。

@flashlin
flashlin / vite.config.js
Created June 16, 2021 00:03
[vite build options] #vite
export default defineConfig({
base: "/dist/",
build: {
//publicPath: process.env.NODE_ENV === "development" ? "/dist/" : "/",
outDir: "../webrtc-server/webrtc-server/wwwroot/dist",
//assetsDir: "./",
emptyOutDir: true,
manifest: true,
// rollupOptions: {
// input: {
@flashlin
flashlin / UserAgentExtension.cs
Last active June 16, 2021 00:04
[DetectBrowserIsMobile] #CSharp
public static class UserAgentExtension
{
static readonly Regex MobileCheck = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
static readonly Regex MobileVersionCheck = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt
@flashlin
flashlin / PyRx
Last active June 16, 2021 00:05
[PyRx Example2] #Python
import asyncio
import rx
import rx.operators as op
import time
from rx.scheduler import ThreadPoolScheduler, NewThreadScheduler
scheduler = ThreadPoolScheduler(2)
scheduler = NewThreadScheduler()
def emitter(observer: rx.typing.Observer, _):
@flashlin
flashlin / PyRx
Last active June 16, 2021 00:05
[PyRx Example1] #Python
import asyncio
from rx import Observer, Observable
from rx.core import Scheduler
def observable_fn(observer):
_task = None
# Customize this
def _setup():
print('Observable setup')
@flashlin
flashlin / .prettierrc
Last active June 16, 2021 00:06
[upgrade to vue 3, vite tsx 2021-05-22] #vue3
{
"tabWidth": 3,
"useTabs": false,
"singleQuote": true,
"semi": false,
"trailingComma": "none"
}
@flashlin
flashlin / readme.md
Created May 15, 2021 12:05
cannot import torch audio ' No audio backend is available.'

You need to install the audio file I/O backend. If Linux it's Sox, if Windows it's SoundFile

To check if you have one set run str(torchaudio.get_audio_backend()) and if 'None' is the result then install the backend.

SoundFile for Windows pip install PySoundFile

Sox for Linux pip install sox

@flashlin
flashlin / index.html
Last active June 16, 2021 00:07
[Calling webpacked code from outside (HTML script tag)] #javascript
<html>
<head>
</head>
<body>
<script src="lib/yourlib.js"></script>
<script>
window.onload = function () {
EntryPoint.run();
};
</script>
@flashlin
flashlin / .wslconfig
Created May 12, 2021 10:44
WSL2 Set Memory Limit in C:\Users\flash\.wslconfig
[wsl2]
memory=2GB
swap=0
localhostForwarding=true