Skip to content

Instantly share code, notes, and snippets.

View lamrongol's full-sized avatar

Lamron lamrongol

View GitHub Profile
chrome.windows.getAll({populate: true, windowTypes: ['normal']}, (windows) => {
const tabId = windows[0].tabs[0].id;
chrome.debugger.attach({ tabId: tabId }, '1.2', () => {
chrome.debugger.sendCommand(
{ tabId: tabId },
'Browser.close'
);
});
})
@lamrongol
lamrongol / detect_main_window_on_chrome_extension.js
Created January 29, 2024 10:04
Detect main window(which has most tabs) and sub(second most tabs).
let mainId, subId;
const detectMainWinodows = () => {
chrome.windows.getAll({populate: true, windowTypes: ['normal']}, (windows) => {
if (windows.length == 1) return;
const sortedWindowIdArray = windows.sort((a, b) => b.tabs.length - a.tabs.length).map((win) => win.id);
mainId = sortedWindowIdArray[0];
subId = sortedWindowIdArray[1];
@lamrongol
lamrongol / flac_wavpack_converter.bat
Last active August 7, 2023 00:29
WavファイルをFlacに変換、もしできなければWavPackに変換(flac、wavpackをダウンロードしPATHを通しておく必要あり。対象フォルダをbatファイルにドラッグ&ドロップ)。e-onkyoがQobuzになり32bit音源を販売しなくなったのでもう不要かも。
echo %~1
rem 指定フォルダ配下(サブフォルダ含む)の全ての対象ファイルに対して処理を行う
for /r "%~1\" %%a in ("*.wav") do (
rem ファイル名を画面へ出力
echo 対象ファイル:"%%a"
flac --delete-input-file "%%a"
if exist "%%a" wavpack -d "%%a"
)
pause
@lamrongol
lamrongol / splitCamelCase
Created March 6, 2015 14:09
Split camel case by using lookahead and lookbehind Zero-Length Assertions of regular expression
/**
* en: Split camel case by using lookahead and lookbehind Zero-Length Assertions of regular expression
* ja:キャメルケースの分割。正規表現のゼロ幅先読みを使用
*
* @param hashTag
* @return "camelCase" -> {"camel", "Case"}, "EMABiggestFans1D" -> {"EMA", "Biggest", "Fans", "1D"} , "MVDvsSSE" -> {"MVD", "SSE"}
* @see <a href="http://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#grouping_constructs">Regular Expression Language - Quick Reference</a>
* @see <a href="http://stackoverflow.com/questions/7593969/regex-to-split-camelcase-or-titlecase-advanced">java - RegEx to split camelCase or TitleCase (advanced) - Stack Overflow</a>
*/
public static String[] splitCamelCase(String hashTag) {
/**
* @see <a href="http://en.wikipedia.org/wiki/Riemann_sum#Middle_sum">http://en.wikipedia.org/wiki/Riemann_sum#Middle_sum</a>
*/
public static double riemannSum(Function<Double, Double> func, double beginPoint, double endPoint, double interval){
double result = 0;
//Middle Sum(Maybe error sum is most minimal)
for(double x = beginPoint; x<=endPoint; x+=interval){
result += func.apply(x+interval/2);
}
result *= interval;