mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-23 14:21:04 +03:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23256695c3 | ||
|
|
69e660bf04 |
No files matched your search
Vendored
+5
-4
@@ -141,10 +141,10 @@ declare module '@vue/runtime-core' {
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NP: typeof import('naive-ui')['NP']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSlider: typeof import('naive-ui')['NSlider']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
NRadio: typeof import('naive-ui')['NRadio']
|
||||
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NTable: typeof import('naive-ui')['NTable']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||
@@ -166,6 +166,7 @@ declare module '@vue/runtime-core' {
|
||||
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
|
||||
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
|
||||
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
|
||||
StacktracePrettier: typeof import('./src/tools/stacktrace-prettier/stacktrace-prettier.vue')['default']
|
||||
StringObfuscator: typeof import('./src/tools/string-obfuscator/string-obfuscator.vue')['default']
|
||||
SvgPlaceholderGenerator: typeof import('./src/tools/svg-placeholder-generator/svg-placeholder-generator.vue')['default']
|
||||
TemperatureConverter: typeof import('./src/tools/temperature-converter/temperature-converter.vue')['default']
|
||||
|
||||
+1
-1
@@ -390,4 +390,4 @@ tools:
|
||||
|
||||
text-to-binary:
|
||||
title: Text to ASCII binary
|
||||
description: Convert text to its ASCII binary representation and vice-versa.
|
||||
description: Convert text to its ASCII binary representation and vice-versa.
|
||||
@@ -58,6 +58,7 @@
|
||||
"cronstrue": "^2.26.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"date-fns": "^2.29.3",
|
||||
"dom-to-image-more": "^3.4.5",
|
||||
"dompurify": "^3.0.6",
|
||||
"email-normalizer": "^1.0.0",
|
||||
"emojilib": "^3.0.10",
|
||||
@@ -67,8 +68,10 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"javastack.js": "^1.0.2",
|
||||
"js-base64": "^3.7.6",
|
||||
"json5": "^2.2.3",
|
||||
"jsstack.js": "^2.0.0",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"libphonenumber-js": "^1.10.28",
|
||||
"lodash": "^4.17.21",
|
||||
@@ -79,11 +82,13 @@
|
||||
"monaco-editor": "^0.43.0",
|
||||
"naive-ui": "^2.35.0",
|
||||
"netmask": "^2.0.2",
|
||||
"netstack.js": "^2.0.0",
|
||||
"node-forge": "^1.3.1",
|
||||
"oui-data": "^1.0.10",
|
||||
"pdf-signature-reader": "^1.4.2",
|
||||
"pinia": "^2.0.34",
|
||||
"plausible-tracker": "^0.3.8",
|
||||
"pythonstack.js": "^1.0.2",
|
||||
"qrcode": "^1.5.1",
|
||||
"randexp": "^0.5.3",
|
||||
"sql-formatter": "^13.0.0",
|
||||
|
||||
Generated
+661
-22
File diff suppressed because it is too large.
Load diff
@@ -2,6 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
import { tool as stacktracePrettier } from './stacktrace-prettier';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
@@ -160,6 +161,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
emailNormalizer,
|
||||
regexTester,
|
||||
regexMemo,
|
||||
stacktracePrettier,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "dom-to-image-more" {
|
||||
export function toPng(el: HTMLElement | undefined, options?: { bgcolor: string }) : Promise<string>;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Stack } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Stacktrace prettier',
|
||||
path: '/stacktrace-prettier',
|
||||
description: 'Highlight .Net and JS stacktraces',
|
||||
keywords: ['stacktrace', 'prettier', 'highlighter'],
|
||||
component: () => import('./stacktrace-prettier.vue'),
|
||||
icon: Stack,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "javastack.js" {
|
||||
export default function javastack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "jsstack.js" {
|
||||
export default function jsstack(selector: string) : void;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
declare module "netstack.js" {
|
||||
export default class netstack {
|
||||
constructor(el: HTMLElement | undefined, options: { prettyprint: boolean })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module "pythonstack.js" {
|
||||
export default function pythonstack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
<script setup lang="ts">
|
||||
import JSStack from 'jsstack.js';
|
||||
import JavaStack from 'javastack.js';
|
||||
import PythonStack from 'pythonstack.js';
|
||||
import NetStack from 'netstack.js';
|
||||
import domtoimage from 'dom-to-image-more';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useStyleStore } from '@/stores/style.store';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const styleStore = useStyleStore();
|
||||
|
||||
const stackType = useQueryParamOrStorage<'net' | 'js' | 'java' | 'python'>({ name: 'type', storageName: 'stackfmt:type', defaultValue: 'net' });
|
||||
const stackTrace = ref('');
|
||||
const formatedStackTrace = ref<HTMLElement>();
|
||||
|
||||
const stackTraceText = ref('');
|
||||
watchEffect(() => {
|
||||
if (!formatedStackTrace.value) {
|
||||
return;
|
||||
}
|
||||
let cleanedStackTrace;
|
||||
try {
|
||||
cleanedStackTrace = JSON.parse(stackTrace.value);
|
||||
}
|
||||
catch (_) {
|
||||
cleanedStackTrace = stackTrace.value.replace(/(\\r)?\\n/g, '\n').replace(/(?:^['"])|(?:['"]$)/, '');
|
||||
};
|
||||
try {
|
||||
if (stackType.value === 'js') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JSStack('.stacktrace');
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JavaStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
PythonStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'net') {
|
||||
formatedStackTrace.value.innerText = cleanedStackTrace;
|
||||
const _ = new NetStack(formatedStackTrace.value, { prettyprint: true });
|
||||
}
|
||||
stackTraceText.value = formatedStackTrace.value.innerText;
|
||||
}
|
||||
catch {}
|
||||
});
|
||||
|
||||
const stackTraceMarkdown = computed(() => {
|
||||
let lang;
|
||||
if (stackType.value === 'net') {
|
||||
lang = 'csharp';
|
||||
}
|
||||
else if (stackType.value === 'js') {
|
||||
lang = 'javascript';
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
lang = 'java';
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
lang = 'python';
|
||||
}
|
||||
return `\`\`\`${lang}\n${formatedStackTrace.value?.innerText}\n\`\`\``;
|
||||
});
|
||||
|
||||
const { copy: copyText } = useCopy({ source: stackTraceText, text: 'Formatted stacktrace copied to the clipboard' });
|
||||
const { copy: copyMarkdown } = useCopy({ source: stackTraceMarkdown, text: 'Markdown Formatted stacktrace copied to the clipboard' });
|
||||
|
||||
async function downloadAsPNG() {
|
||||
const dataUrl = await domtoimage.toPng(formatedStackTrace.value, { bgcolor: styleStore.isDarkTheme ? '#333' : '#fff' });
|
||||
const link = document.createElement('a');
|
||||
link.download = 'stacktrace.png';
|
||||
link.href = dataUrl;
|
||||
link.click();
|
||||
}
|
||||
|
||||
const wrap = ref(true);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div max-w-600px>
|
||||
<n-radio-group v-model:value="stackType" name="radiogroup" mb-2 flex justify-center>
|
||||
<n-space>
|
||||
<n-radio
|
||||
value="net"
|
||||
label=".Net"
|
||||
/>
|
||||
<n-radio
|
||||
value="js"
|
||||
label="Javascript"
|
||||
/>
|
||||
<n-radio
|
||||
value="python"
|
||||
label="Python"
|
||||
/>
|
||||
<n-radio
|
||||
value="java"
|
||||
label="Java"
|
||||
/>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
|
||||
<div mb-2 flex justify-center>
|
||||
<n-checkbox v-model:checked="wrap">
|
||||
Wrap lines?
|
||||
</n-checkbox>
|
||||
</div>
|
||||
<c-input-text
|
||||
v-model:value="stackTrace"
|
||||
label="Stacktrace"
|
||||
placeholder="Paste your stacktrace here.."
|
||||
multiline
|
||||
rows="5"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<pre ref="formatedStackTrace" class="stacktrace" :style="{ padding: '20px', whiteSpace: wrap ? 'pre-wrap' : 'pre', overflowX: 'auto', wordBreak: 'break-all' }" />
|
||||
|
||||
<div v-if="stackTraceText" flex justify-center gap-1>
|
||||
<c-button @click="copyText()">
|
||||
Copy Formatted (Text)
|
||||
</c-button>
|
||||
<c-button @click="copyMarkdown()">
|
||||
Copy Formatted (Markdown)
|
||||
</c-button>
|
||||
<c-button @click="downloadAsPNG()">
|
||||
Download as PNG
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
::v-deep(.stacktrace) {
|
||||
pre, code {background-color:#333 !important; color: #fff !important;}
|
||||
.st-type {color: #0a8472; font-weight: bolder;}
|
||||
.st-method {color: #70c9ba; font-weight: bolder;}
|
||||
.st-frame-params {color: #ffffff; font-weight: normal;}
|
||||
.st-param-type {color: #0a8472;}
|
||||
.st-param-name {color: #ffffff;}
|
||||
.st-file {color:#f8b068;}
|
||||
.st-line {color:#ff4f68;}
|
||||
.st-methodName {color: #70c9ba;font-weight: bolder;}
|
||||
.st-column {color: #f8b068;}
|
||||
.st-lineNumber {color: #ff4f68;}
|
||||
.st-fileName {color: #85dbff;}
|
||||
.st-intro {color: #0044dd;}
|
||||
.st-exception {color: #e40000;}
|
||||
}
|
||||
</style>
|
||||
@@ -94,19 +94,5 @@ describe('token-generator', () => {
|
||||
expect(token).toHaveLength(256);
|
||||
expect(token).toMatch(/^[a-zA-Z]+$/);
|
||||
});
|
||||
|
||||
it('should generate a random string with just numbers except 1 and 2 if only withNumbers is set and deniedChars contains 1 and 2', () => {
|
||||
const token = createToken({
|
||||
withLowercase: false,
|
||||
withUppercase: false,
|
||||
withNumbers: true,
|
||||
withSymbols: false,
|
||||
length: 256,
|
||||
deniedChars: '12',
|
||||
});
|
||||
|
||||
expect(token).toHaveLength(256);
|
||||
expect(token).toMatch(/^[03456789]+$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -5,7 +5,6 @@ export function createToken({
|
||||
withLowercase = true,
|
||||
withNumbers = true,
|
||||
withSymbols = false,
|
||||
deniedChars = '',
|
||||
length = 64,
|
||||
alphabet,
|
||||
}: {
|
||||
@@ -13,17 +12,15 @@ export function createToken({
|
||||
withLowercase?: boolean
|
||||
withNumbers?: boolean
|
||||
withSymbols?: boolean
|
||||
deniedChars?: string
|
||||
length?: number
|
||||
alphabet?: string
|
||||
}) {
|
||||
const allAlphabet = (alphabet ?? (
|
||||
(withUppercase ? 'ABCDEFGHIJKLMOPQRSTUVWXYZ' : '')
|
||||
+ (withLowercase ? 'abcdefghijklmopqrstuvwxyz' : '')
|
||||
+ (withNumbers ? '0123456789' : '')
|
||||
+ (withSymbols ? '.,;:!?./-"\'#{([-|\\@)]=}*+' : '')
|
||||
)).split('').filter(c => !(deniedChars?.includes(c))).join('');
|
||||
const allAlphabet = alphabet ?? [
|
||||
withUppercase ? 'ABCDEFGHIJKLMOPQRSTUVWXYZ' : '',
|
||||
withLowercase ? 'abcdefghijklmopqrstuvwxyz' : '',
|
||||
withNumbers ? '0123456789' : '',
|
||||
withSymbols ? '.,;:!?./-"\'#{([-|\\@)]=}*+' : '',
|
||||
].join('');
|
||||
|
||||
const len = length < 1 ? 1 : length;
|
||||
return shuffleString(allAlphabet.repeat(len)).substring(0, len);
|
||||
return shuffleString(allAlphabet.repeat(length)).substring(0, length);
|
||||
}
|
||||
@@ -1,88 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import { createToken } from './token-generator.service';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useQueryParam } from '@/composable/queryParams';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
|
||||
const count = useQueryParamOrStorage({ name: 'count', storageName: 'token-generator:count', defaultValue: 1 });
|
||||
const length = useQueryParamOrStorage({ name: 'length', storageName: 'token-generator:length', defaultValue: 64 });
|
||||
const withUppercase = useQueryParamOrStorage({ name: 'uppercase', storageName: 'token-generator:uppercase', defaultValue: true });
|
||||
const withLowercase = useQueryParamOrStorage({ name: 'lowercase', storageName: 'token-generator:lowercase', defaultValue: true });
|
||||
const withNumbers = useQueryParamOrStorage({ name: 'numbers', storageName: 'token-generator:numbers', defaultValue: true });
|
||||
const withSymbols = useQueryParamOrStorage({ name: 'symbols', storageName: 'token-generator:symbols', defaultValue: false });
|
||||
const deniedChars = useQueryParamOrStorage({ name: 'deny', storageName: 'token-generator:deny', defaultValue: '' });
|
||||
const length = useQueryParam({ name: 'length', defaultValue: 64 });
|
||||
const withUppercase = useQueryParam({ name: 'uppercase', defaultValue: true });
|
||||
const withLowercase = useQueryParam({ name: 'lowercase', defaultValue: true });
|
||||
const withNumbers = useQueryParam({ name: 'numbers', defaultValue: true });
|
||||
const withSymbols = useQueryParam({ name: 'symbols', defaultValue: false });
|
||||
const { t } = useI18n();
|
||||
|
||||
const [tokens, refreshTokens] = computedRefreshable(() =>
|
||||
Array.from({ length: count.value < 1 ? 1 : count.value },
|
||||
() => createToken({
|
||||
length: length.value,
|
||||
withUppercase: withUppercase.value,
|
||||
withLowercase: withLowercase.value,
|
||||
withNumbers: withNumbers.value,
|
||||
withSymbols: withSymbols.value,
|
||||
deniedChars: deniedChars.value,
|
||||
})).join('\n'),
|
||||
const [token, refreshToken] = computedRefreshable(() =>
|
||||
createToken({
|
||||
length: length.value,
|
||||
withUppercase: withUppercase.value,
|
||||
withLowercase: withLowercase.value,
|
||||
withNumbers: withNumbers.value,
|
||||
withSymbols: withSymbols.value,
|
||||
}),
|
||||
);
|
||||
|
||||
const { copy } = useCopy({ source: tokens, text: t('tools.token-generator.copied') });
|
||||
const { copy } = useCopy({ source: token, text: t('tools.token-generator.copied') });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-card>
|
||||
<n-form label-placement="left" label-width="140">
|
||||
<n-space justify="center">
|
||||
<n-form-item :label="t('tools.token-generator.uppercase')">
|
||||
<n-switch v-model:value="withUppercase" />
|
||||
</n-form-item>
|
||||
<div flex justify-center>
|
||||
<div>
|
||||
<n-form-item :label="t('tools.token-generator.uppercase')">
|
||||
<n-switch v-model:value="withUppercase" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item :label="t('tools.token-generator.lowercase')">
|
||||
<n-switch v-model:value="withLowercase" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('tools.token-generator.numbers')">
|
||||
<n-switch v-model:value="withNumbers" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('tools.token-generator.lowercase')">
|
||||
<n-switch v-model:value="withLowercase" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<n-form-item :label="t('tools.token-generator.symbols')">
|
||||
<n-switch v-model:value="withSymbols" />
|
||||
</n-form-item>
|
||||
</n-space>
|
||||
<div>
|
||||
<n-form-item :label="t('tools.token-generator.numbers')">
|
||||
<n-switch v-model:value="withNumbers" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item :label="t('tools.token-generator.symbols')">
|
||||
<n-switch v-model:value="withSymbols" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</n-form>
|
||||
|
||||
<n-form-item label="Denied Characters (ie, visually similar { oO01lI } or punctuations)" label-placement="top">
|
||||
<c-input-text
|
||||
v-model:value="deniedChars"
|
||||
placeholder="Put characters to deny from token"
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item :label="`${t('tools.token-generator.length')} (${length})`" label-placement="left">
|
||||
<n-slider v-model:value="length" :step="1" :min="1" :max="512" mr-2 />
|
||||
<n-input-number v-model:value="length" :min="1" :max="512" size="small" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="Number of token to generate" label-placement="left">
|
||||
<n-slider v-model:value="count" :step="1" :min="1" mr-2 />
|
||||
<n-input-number v-model:value="count" :min="1" size="small" />
|
||||
<n-slider v-model:value="length" :step="1" :min="1" :max="512" />
|
||||
</n-form-item>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="tokens"
|
||||
v-model:value="token"
|
||||
multiline
|
||||
:placeholder="t('tools.token-generator.tokenPlaceholder')"
|
||||
readonly
|
||||
rows="3"
|
||||
autosize
|
||||
class="token-display"
|
||||
word-wrap
|
||||
/>
|
||||
|
||||
<div mt-5 flex justify-center gap-3>
|
||||
<c-button @click="copy()">
|
||||
{{ t('tools.token-generator.button.copy') }}
|
||||
</c-button>
|
||||
<c-button @click="refreshTokens">
|
||||
<c-button @click="refreshToken">
|
||||
{{ t('tools.token-generator.button.refresh') }}
|
||||
</c-button>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user