Skip to content

Instantly share code, notes, and snippets.

View ManUtopiK's full-sized avatar
:octocat:
Ready to code.

Emmanuel Salomon ManUtopiK

:octocat:
Ready to code.
View GitHub Profile
@ManUtopiK
ManUtopiK / make-variable.ts
Created September 21, 2024 19:36
unocss make variable
export const shades = [
50,
...Array.from({ length: 9 }).map((_, i) => (i + 1) * 100),
950,
];
export const makeVariable = ({ fallbackValue, name, shade, withVar }) => {
const variable = `--${name}-${shade}`;
const value = fallbackValue ? variable + ", " + fallbackValue : variable;
return withVar ? `var(${value})` : variable;
@ManUtopiK
ManUtopiK / remoteScript.js
Created September 12, 2024 01:40
test remote script
// remoteScript.js
(function() {
// Define a global function
window.remoteFunction = function() {
console.log('Remote function called!');
// You can add more functionality here
};
// Optionally, you can define more functions or objects
window.anotherRemoteFunction = function(message) {
@ManUtopiK
ManUtopiK / gitlab-webhook.ts
Created July 16, 2024 19:29
Gitlab webhook to refresh nuxt-content
import { defineEventHandler, getRequestHeader, readBody } from 'h3'
import { transformContent } from '@nuxt/content/transformers'
// @ts-expect-error Missing imports
import { useStorage, useRuntimeConfig } from '#imports'
export default defineEventHandler(async (event) => {
const secret = getRequestHeader(event, 'X-Gitlab-Token')
const body = await readBody(event)
const commits = body.commits
const config = useRuntimeConfig()
@ManUtopiK
ManUtopiK / useBreadcrumbs.ts
Created December 1, 2023 12:23
useBreadcrumbs for Vue
const isMathPatternPath = (pathA: string, pathB: string) => {
const partsA = pathA.split('/');
const partsB = pathB.split('/');
if (partsA.length !== partsB.length) return false;
const isMatch = partsA.every((part: string, i: number) => {
return part === partsB[i] || part.startsWith(':');
})
@ManUtopiK
ManUtopiK / landingpages.spec.ts
Created October 19, 2023 20:41 — forked from CodeDredd/landingpages.spec.ts
Full e2e test example with nuxt 3
import { fileURLToPath } from 'node:url';
import { describe, test } from 'vitest';
import { expect } from '@playwright/test';
import { setup, createPage } from '@nuxt/test-utils';
describe('Landing page', async () => {
await setup({
rootDir: fileURLToPath(new URL('..', import.meta.url)),
server: true,
browser: true,
@ManUtopiK
ManUtopiK / index.md
Created August 20, 2023 23:18
Basic Markdown Formatting
date title category tags
2022-08-10
Basic Markdown Formatting
Tutorial
vue

The Ultimate Guide to Markdown. This will also be bold

@ManUtopiK
ManUtopiK / git_commit_and_push.sh
Created August 19, 2023 15:31
git_commit_and_push.sh
#!/bin/bash
# Check if the user provided the branch name and commit message as arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <branch_name> <commit_message>"
exit 1
fi
branch_name="$1"
commit_message="$2"
@ManUtopiK
ManUtopiK / index.js
Created July 23, 2023 17:06
Netlify edge function's geo prop
export default async (request, context) => {
return new Response(
JSON.stringify({
...context.geo,
ip: context.ip,
}),
{ headers: { 'content-type': 'application/json' } }
);
};
#!/bin/bash
OPTION=$1
HOSTNAME=$(hostname)
DATE=$(date +%Y-%m-%d-%H-%M-%S)
REPORT_FILE="report-${HOSTNAME}-${DATE}.txt"
INTERESTING_FILES='.bash_history .bash_logout .bashrc .ssh known_hosts authorized_keys id_rsa id_rsa.pub authorized_keys2'
INTERESTING_PLACES='/var /tmp /dev/shm'
COMPRESSED_FILE_EXTENSIONS='.zip .tar .gz .rar'
@ManUtopiK
ManUtopiK / urql.ts
Created March 9, 2023 00:45 — forked from productdevbook/urql.ts
Nuxt 3 urql graphql
import { Client, createClient, dedupExchange, errorExchange, fetchExchange, ssrExchange } from '@urql/core'
import { ref } from 'vue'
import { devtoolsExchange } from '@urql/devtools'
import * as Session from 'supertokens-web-js/recipe/session'
import { authExchange } from '@urql/exchange-auth'
import { defineNuxtPlugin } from '#app'
const ssrKey = '__URQL_DATA__'
export default defineNuxtPlugin((nuxtApp) => {