Skip to content

Instantly share code, notes, and snippets.

View nainemom's full-sized avatar
🕺

Amir Momenian nainemom

🕺
View GitHub Profile
@nainemom
nainemom / app.js
Last active March 2, 2024 19:52
listhen + h3 error capturing issue reproduction
import { createApp, defineEventHandler, createError } from "h3";
export const app = createApp({
onError: () => console.error('Captured!'),
});
app.use('/error', defineEventHandler(async () => {
throw createError({
statusCode: 400,
});
@nainemom
nainemom / subtranslate.lua
Last active April 26, 2024 04:03
MPV script to translate current line of subtitle
-- Simple mpv script to translate subtitle using crow (online) or sdcv (offline) dictionaries.
-- INSTALLATION:
-- To install it, first install crow (https://crow-translate.github.io) and/or sdcv (http://dushistov.github.io/sdcv/) on your marchine with your favorite dicts and then,
-- copy this file to '~/.config/mpv/scripts/' (Linux) or '%AppData%\mpv\scripts\' (Windows).
-- sdcv help:
-- you can download offline dicts from http://download.huzheng.org/Quick/ (or anywhere else) and copy extracted dic folder to '~/.stardict/dic/'
-- CONFIGURATION:
local config = {
@nainemom
nainemom / jz.bash
Created December 26, 2019 15:47
جدول ضرب
line="=================================================================================";
printStuff="x | 1 2 3 4 5 6 7 8 9 ";
echo -e $printStuff;
echo $line;
i=1;
for (( i=1; i<10; i++ ))
do
printStuff="${i} | ";
for (( j=1; j<10; j++ ))
do
@nainemom
nainemom / cli.js
Last active January 4, 2020 21:07
Simple CLI Tool for Node.js
const readline = require('readline');
const process = require('process');
module.exports.ask = (question) => new Promise((resolve) => {
const createdInterface = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
createdInterface.question(`${question} `, (answer) => {
createdInterface.close();
@nainemom
nainemom / simple-encoder.js
Last active December 7, 2020 18:35
Very simple Javascript string encode and decoder
function encoder(str, numericPass = 1234, decode = false) {
return str.split('').map(c => String.fromCharCode((c.charCodeAt(0) + ((decode ? -1 : 1) * numericPass)) % 256)).join('')
}
@nainemom
nainemom / einstein.js
Last active July 4, 2019 22:31
Einstein's Five-House Riddle Solver with JavaScript
// Einstein's Five-House Riddle Solver
// Original question: https://udel.edu/~os/riddle.html
// by Nainemom <[email protected]>
const print = (colors, nations, drinks, pets, cigars, time) => {
console.log('')
console.log('-'.repeat(103))
console.log(['#1', '#2', '#3', '#4', '#5'].join("\t\t\t"))
console.log('-'.repeat(103))
console.log(colors.join("\t\t\t"))