Skip to content

Instantly share code, notes, and snippets.

View flashlin's full-sized avatar

Mr.Flash flashlin

  • Taiwan
View GitHub Profile
@flashlin
flashlin / Error.aspx
Last active August 18, 2020 04:59
Global Error Handle #aspnet #errorHandle
<asp:Content ID="errorContent" ContentPlaceHolderID="MainContent" runat="server">
<h2><%= Html.Encode(ViewData["Title"]) %></h2>
<p><%= Html.Encode(ViewData["Description"])%></p>
<div>
<%= Html.ActionLink("返回首頁", "Index", "Home") %>.
</div>
</asp:Content>
@flashlin
flashlin / BasicSystemUnderTest.cs
Last active August 28, 2020 13:57
System Under Test (SUT) Integration Test for dotnet core 3 #test #aspnetcore3
public class BasicSystemUnderTest<TStartup> : IClassFixture<WebApplicationFactory<TStartup>>
where TStartup : class
{
protected readonly WebApplicationFactory<TStartup> _factory;
public BasicSystemUnderTest(WebApplicationFactory<TStartup> factory)
{
_factory = factory;
}
@flashlin
flashlin / Listen.ts
Last active June 16, 2021 00:09
[Chrome Extension WebRequest Hook] #chrome-extension #typescript
(function () {
const tabStorage = {};
const networkFilters = {
urls: ["*://*/*"],
};
chrome.webRequest.onBeforeRequest.addListener((details) => {
const { tabId, requestId } = details;
if (!tabStorage.hasOwnProperty(tabId)) {
return;
@flashlin
flashlin / hook.ts
Created February 27, 2021 00:35
xhook ajax
document.onreadystatechange = function () {
console.log("test", document.readyState);
if (document.readyState === "interactive") {
var modif2 = document.createElement("script");
modif2.type = "text/javascript";
modif2.src = "https://unpkg.com/xhook@1.4.9/dist/xhook.min.js";
document.getElementsByTagName("head")[0].appendChild(modif2);
console.log("--- inserted src ----");
} else if (document.readyState === "complete") {
@flashlin
flashlin / index.html
Created April 13, 2021 06:25
[How to pass html template as props to Vue component] #vue
<script src="https://unpkg.com/vue"></script>
<div id="app">
<my-component>
<p class="textbox">hell
o world1</p>
<p class="textbox">hello world2</p>
</my-component>
</div>
@flashlin
flashlin / example
Created April 16, 2021 01:17
[Split a list into parts based on a set of indexes in Python] #python
indexes = [5, 12, 17]
list = range(20)
part1 = list[:5]
part2 = list[5:12]
part3 = list[12:17]
part4 = list[17:]
from itertools import izip, chain
def partition(alist, indices):
@flashlin
flashlin / jmeter.bat
Last active May 12, 2021 14:06
JMeter setting
if not defined HEAP (
rem See the unix startup file for the rationale of the following parameters,
rem including some tuning recommendations
set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)
@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
@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 / 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