Skip to content

Instantly share code, notes, and snippets.

const { PlaywrightCrawler } = require("crawlee");
const { firefoxUserPrefs } = require("./firefox-user-prefs"); // this just some firefox setting in this repo https://github.com/yokoffing/BetterFox
const constNike = require("./const");
const currentDir = __dirname;
const path = require("path");
const { firefox } = require("playwright");
const { expect } = require("playwright/test");
const imageFolder = path.join(currentDir, "images");
const SimpleNodeLogger = require("simple-node-logger");
const fs = require("fs");
@lechuhuuha
lechuhuuha / box.php
Created January 8, 2024 09:23
Box Spout php excel for large file
<?php
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
function genLogs($progressCallback, $defaultHeader, $customHeader, $ipHeader = [], $model, $total)
{
$headers = array_merge($defaultHeader, array_values($customHeader), $ipHeader);
$model = '\EMA\Model\MongoDB\\' . $model;
$tmpTableName = 'log_' . $this->uid . '_' . md5(rand());
<?php
public function showLoginForm(\Illuminate\Http\Request $request)
{
$sso_url = env('SSO_URL', '#') . '?callback_url=' . action('Controller@loginSSO');
return view('auth.login', ['sso_url' => $sso_url]);
}
@lechuhuuha
lechuhuuha / test.php
Last active October 25, 2023 09:19
php monitor
<?php
$monitors = Monitor::doesntHave('uptimeRecords')->select('id', 'url')->limit(10)->get();
$countMonitorsWithoutUTR = $monitors->count();
if ($countMonitorsWithoutUTR < 10) {
$orderByDescUptimeRecord = UptimeRecord::select('id_monitor')
->selectRaw('MAX(checked_at) as max_checked_at')
->groupBy('id_monitor')
->orderBy('max_checked_at', 'asc')
@lechuhuuha
lechuhuuha / terminal.js
Created August 29, 2023 09:21
terminaljs
let terminal = new Terminal({
cols: 128,
rows: 13,
convertEol: true,
cursorBlink: true,
});
terminal.open(document.getElementById("terminal"));
let bearToken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7Im9yaWdpbl91c2VybmFtZSI6IiIsInVzZXJuYW1lIjoicm9vdCJ9LCJpc3MiOiJzaW1wbGUtcGFuZWwiLCJzdWIiOiJhY2Nlc3MtdG9rZW4iLCJleHAiOjE2OTMzNTM2MDAsIm5iZiI6MTY5MzI3NTY2NSwiaWF0IjoxNjkzMjc1NjY1fQ.Jn6YSpW8F_GoUSXE-GtN-fgsEZXyy1Y5jjoe8vcuGzw";
let protocol = location.protocol === "https:" ? "wss://" : "ws://";
@lechuhuuha
lechuhuuha / xterm.js
Created August 24, 2023 04:28
xtermjs
(function () {
let terminal = new Terminal({
screenKeys: true,
useStyle: true,
cursorBlink: true,
fullscreenWin: true,
maximizeWin: true,
screenReaderMode: true,
cols: 128,
});
func (u *UserRepository) ListUserName(ctx context.Context, req *repositories.ListUserRequest) ([]*models.UserModel, error) {
	qb := squirrel.Select("username").From(u.tableName).PlaceholderFormat(PlaceHolder)

	if req.Owner != "" {
		if req.Owner != "root" {
			qb = qb.Where(squirrel.Eq{"owner": req.Owner})
		}
	}