Skip to content

Instantly share code, notes, and snippets.

@thim81
thim81 / prisma.validation.js
Last active January 5, 2024 07:43
Prisma Simple Schema Validation
import path, {dirname} from "path";
import {fileURLToPath} from "url";
import prismaInternals from '@prisma/internals';
const {getDMMF} = prismaInternals;
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export const validateRequestPayload = async (modelName, requestBody) => {
try {
@thim81
thim81 / .env
Created January 16, 2022 13:53
Auth0 - Outh2 token - Generate Postman Environment file
NODE_ENV=pipeline
BASEURL=https://example.com/api
OAUTH_BASE_URL=https://[enter-your-own].auth0.com
OAUTH_ACCESS_TOKEN_URL=https://[enter-your-own].auth0.com/oauth/token
OAUTH_CLIENT_ID=___INSERT_HERE_YOUR_AUTH0_CLIENT_ID___
OAUTH_CLIENT_SECRET=___INSERT_HERE_YOUR_AUTH0_CLIENT_SECRET___
OAUTH_AUDIENCE=___INSERT_HERE_YOUR_AUTH0_AUDIENCE___
OAUTH_ACCOUNT_ID=___INSERT_HERE_YOUR_AUTH0_ACCOUNT_ID___
OAUTH_GRANT_TYPE=client_credentials
OAUTH_TOKEN_URL=https://[enter-your-own].auth0.com
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@thim81
thim81 / auht0.postman_environment.json
Created June 14, 2021 06:02
Auth0 - Outh2 - Postman pre-request script
{
"name": "Auth0-Oauth2",
"values": [
{
"key": "baseUrl",
"value": "https://example.com/api",
"enabled": true
},
{
"key": "oauth_access_token",
@thim81
thim81 / save-blob-ctrl.js
Created June 13, 2019 14:38 — forked from mir4ef/save-blob-ctrl.js
Save a blob file in AngularJS 1.x
function SaveFileCtrl (SaveFileService) {
var vm = this;
function downloadFile(someArgument) {
SaveFileService.downloadFile({
param: someArgument
}, function (response) {
var fileName = response.headers['content-disposition'].split("=")[1].replace(/\"/gi,'');
var fileType = response.headers['content-type'] + ';charset=utf-8';
var blob = new Blob([response.data], { type: fileType });
@thim81
thim81 / .htaccess
Created May 8, 2019 07:04 — forked from nurtext/.htaccess
Tell apache we're on HTTPS if reverse proxy is serving the site using SSL
# Let apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
# Redirect to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IFModule>
@thim81
thim81 / RetrieveEmailCommand.php
Created June 7, 2016 21:15 — forked from gmoqa/RetrieveEmailCommand.php
Symfony2 command to retrieve and save, emails by IMAP, save the email, attachments and analize a email content for set a specific Entity.
<?php
namespace AppBundle\Command;
use AppBundle\Entity\Evento;
use AppBundle\Entity\EventoAdjunto;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;