Skip to content

Instantly share code, notes, and snippets.

View wermarter's full-sized avatar
🐹
lọ mọ

Hà Minh Chiến wermarter

🐹
lọ mọ
View GitHub Profile
@wermarter
wermarter / parent_dir.sh
Created October 14, 2023 02:05
find current dir and parent dir of running script
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PARENT_DIR=$( dirname $SCRIPT_DIR )
@wermarter
wermarter / generator.js
Created September 27, 2023 02:13
javascript generator vs stream API
const nReadlines = require("n-readlines");
const fs = require("fs");
const events = require('events');
main().then(() => {
const used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(
`The script uses approximately ${Math.round(used * 100) / 100} MB`
);
@wermarter
wermarter / ssh.bat
Created July 16, 2023 01:50
"remote.SSH.path": "C:\\ssh.bat"
C:\Windows\system32\wsl.exe ssh %*
@wermarter
wermarter / main.ts
Created May 26, 2023 02:50
nestjs-cargo-queue
export class BaseWorkerService<TaskInput, TaskOutput> {
private queue: QueueObject<TaskInput>;
private logger: Logger;
private workCounter = 0;
constructor(
workerName: string,
concurrency: number,
batchSize: number,
batchProcessor: (input: TaskInput[]) => Promise<TaskOutput[]>,
@wermarter
wermarter / timeout_function.js
Last active November 18, 2021 12:05
Timeout function execution
const timeout_function = async (func, timeLimit) => {
return new Promise((resolve, reject) => {
const timer = setTimeout(() => {
console.log("Timeout reached");
reject(null);
}, timeLimit);
const result = func();
resolve(result);
@wermarter
wermarter / recode.py
Created December 19, 2017 02:03
Using FFMPEG to recode to 480p from text file contains list of dir
import os
from TheFetchers.TheCommons import filename_check
with open(input('> '), 'r') as f:
files = [i.strip() for i in f.readlines()]
for file in files:
fn = os.path.splitext(file)[0]+'.mp4'
output_file = filename_check(fn, True)
cmd = "ffmpeg -i \"%s\" -vf scale=-2:480 -c:v libx264 \"%s\"" % (file, output_file)
os.system(cmd)
import origami
APP_TOKEN = "nongh::2113789:5001:8000:54.158.186.33"
app = origami.register(APP_TOKEN)
@origami.crossdomain
@app.listen()
def concat():
allText = origami.getTextArray()
import tensorflow as tf
import tflearn
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
import cv2
import tflearn.datasets.mnist as mnist
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
import tensorflow as tf
import tflearn
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
import tflearn.datasets.mnist as mnist
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
TENSORBOARD_DIR='./tmp/tflearn/vae'
@wermarter
wermarter / myVAE.py
Last active June 22, 2017 11:27
my implementation of Variational AutoEncoder with tflearn
import tensorflow as tf
import tflearn
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
import tflearn.datasets.mnist as mnist
trainX, trainY, testX, testY = mnist.load_data(one_hot=True)
TENSORBOARD_DIR='./logs/vae'