Skip to content

Instantly share code, notes, and snippets.

@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 22, 2024 03:29
set -e, -u, -o, -x pipefail explanation
@bbirec
bbirec / util.sql
Last active May 22, 2024 03:29
Postgres 유용한 query모음.
-- auto vaccum이 되었던 시간과 개수
select relname, autovacuum_count, last_autovacuum::timestamp with time zone at time zone 'Asia/Seoul' from pg_stat_all_tables where last_autovacuum is not null order by last_autovacuum desc limit 20;
-- 현재 실행중인 query
SELECT pid,query,now()-query_start as diff,query_start,state_change FROM pg_stat_activity where state='active' order by query_start desc;
-- 실행중인 pid kill
SELECT pg_terminate_backend(
--pid
@hbsdev
hbsdev / clean_py.sh
Last active May 22, 2024 03:27 — forked from joelverhagen/clean_py.sh
Recursively remove all .pyc files and __pycache__ directories in the current directory.
#!/bin/sh
# recursively removes all .pyc files and __pycache__ directories in the current
# directory
find . | grep -E "(__pycache__|\.pyc$)" | xargs rm -rf
@BYJRK
BYJRK / CancelableThreadTask.cs
Created May 21, 2024 14:07
Wrap a long-running synchronous method into an asynchronous method and provide cancellation functionality.
public class CancelableThreadTask
{
private Thread? _thread;
private readonly Action _action;
private readonly Action<Exception>? _onError;
private readonly Action? _onCompleted;
private TaskCompletionSource? _tcs;
private int _isRunning = 0;
@YimianDai
YimianDai / MixupDetection.md
Last active May 22, 2024 03:21
MixupDetection

首先需要明确的是 MixupDetection 这个类是在 VOCDetection 类之上的一个 wrapper,因为 mixup 这个技巧/方法可以简单的认为是一个 Data Augmentation 的手段。传统的 Data Augmentation 手段:裁剪、翻转 / 旋转、尺度变化,mixup 的做法在于将两幅图像按照随机权重相加。

MixupDetection 的实现考虑了两幅图像的大小可能是不同的,因此 mixup 后的图像为最大的图像,因此代码中 mixup 图像由下得到

        height = max(img1.shape[0], img2.shape[0])
        width = max(img1.shape[1], img2.shape[1])
        mix_img = mx.nd.zeros(shape=(height, width, 3), dtype='float32')
@ericchansen
ericchansen / monitor_usb.ps1
Created May 24, 2023 18:19
PowerShell script to monitor device connects and disconnects on Windows.
$CurrentState = $null
$NewState = $null
Write-Host "Monitoring device changes..." -ForegroundColor Green
while ($true) {
if (-not($CurrentState)) {
$CurrentState = Get-PnpDevice -Status OK
}
else {
$NewState = Get-PnpDevice -Status OK
$Changes = $null
@v1mkss
v1mkss / JetBrains Activation.md
Last active May 22, 2024 03:18
JetBrains Activation

JetBrains Activation

  • No proxy for:
*.apache.org, *.github.com, *.github.io, *.githubusercontent.com, *.gitlab.com, *.google.com, *.gradle.org, *.jetbrains.space, *.maven.org, *.micronaut.io, *.quarkus.io, *.scala-sbt.org, *.schemastore.org, *.spring.io, cache-redirector.jetbrains.com, cloudconfig.jetbrains.com, download-cdn.jetbrains.com, download.jetbrains.com, downloads.marketplace.jetbrains.com, ea-report.jetbrains.com, github.com, gitlab.com, google.com, gradle.org, jcenter.bintray.com, jitpack.io, micronaut.io, plugins.jetbrains.com, quarkus.io, repo.papermc.io, resources.jetbrains.com, spring.io, www.jetbrains.com

Activation Key:

UX394X3HLT-eyJsaWNlbnNlSWQiOiJVWDM5NFgzSExUIiwibGljZW5zZWVOYW1lIjoiSG9uZ2lrIFVuaXZlcnNpdHntmY3snbXrjIDtlZnqtZAiLCJsaWNlbnNlZVR5cGUiOiJDTEFTU1JPT00iLCJhc3NpZ25lZU5hbWUiOiLkvJfliJvkupEg5bel5L2c5a6kIiwiYXNzaWduZWVFbWFpbCI6ImhhbmF6YXdhbWl0b0BnbWFpbC5jb20iLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJG
@grahamperrin
grahamperrin / freebsd-descriptive-repo-names.md
Last active May 22, 2024 03:16
Using descriptive repository names for FreeBSD-provided and locally-built packages

Using descriptive repository names for FreeBSD-provided and locally-built packages

Three distinctive names

% pkg -vv | grep -B 1 -e url -e priority
  FreeBSD-ports: { 
    url             : "pkg+https://pkg.freebsd.org/FreeBSD:15:amd64/latest",
    enabled         : yes,
 priority : 2,
@nickrouty
nickrouty / rd-class-text-extraction.php
Created May 9, 2018 04:14
Class for extraction the text from doc, docx, xlsx, pptx and wrapper for 3rd party pdf to text library.
<?php
/**
* Class RD_Text_Extraction
*
* Example usage:
*
* $response = RD_Text_Extraction::convert_to_text($path_to_valid_file);
*
* For PDF text extraction, this class requires the Smalot\PdfParser\Parser class.
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except: