Skip to content

Instantly share code, notes, and snippets.

View leog's full-sized avatar
☺️
Upbeat

Leo Giovanetti leog

☺️
Upbeat
View GitHub Profile
@leog
leog / page.ts
Last active May 2, 2024 14:58
Next-Auth Server-side Sign in
import { AuthHandler } from "node_modules/next-auth/core";
import { getServerAuthSession } from "@/server/auth";
import { cookies, headers } from "next/headers";
import { getCsrfToken } from "next-auth/react";
import { authOptions } from "@/server/auth";
import { type AuthAction } from "next-auth";
import { redirect } from "next/navigation";
import { createHash } from "crypto";
export default async function Page({
@leog
leog / seed.ts
Created July 30, 2023 17:04
Generate Fake Users and Teams with members
/* Requires faker v8.0.2 */
/* TODO: Replace "@acme.com with also a fake domain */
// Generates defined number of random users, with extraFields as needed
async function generateFakeUsers({
count = 1,
extraFields,
}: {
count: number;
@leog
leog / api_generator.js
Created March 12, 2022 02:51 — forked from v1vendi/api_generator.js
REST API functional generator
const fetch = (...args) => console.log(...args) // mock
function httpRequest(url, method, data) {
const init = { method }
switch (method) {
case 'GET':
if (data) url = `${url}?${new URLSearchParams(data)}`
break
case 'POST':
case 'PUT':
case 'PATCH':
@leog
leog / tsconfig.json
Last active October 19, 2021 21:42
Configuración TypeScript
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"outDir": "docs",
"sourceMap": true,
"target": "ES6",
"noImplicitAny": true,
"noImplicitReturns": true,
"strict": true,
@leog
leog / script.js
Created September 29, 2021 00:21
Modal base (sin modularización ni función constructora)
const button = document.querySelector('button');
let modal;
let backdrop;
button.addEventListener('click', showModalHandler);
function showModalHandler() {
if (modal) {
return;
@leog
leog / folder_index.html
Created January 15, 2021 21:30
directory_index.rb
<html>
<head>
<title>${header}</title>
<meta name="description" content="${header}"/>
</head>
<body>
${readme_content}
<hr>
<table>
@leog
leog / directory_listing.rb
Last active January 15, 2021 15:06 — forked from teiko/directory_listing.rb
Directory Listing Plugin for Jekyll
# Title: Directory Listing Plugin for Jekyll
# Author: Simon Heimlicher http://simon.heimlicher.com
# Description: Display list of pages and directories beneath current directory
# Configuration: You can set default title in _config.yml as follows:
# directory_listing_title: "Contents: "
# directory_listing_prefix: "Contents of "
#
# Syntax {% directory_listing Title of Listing %}
#
# Example 1:
@leog
leog / pre-request_script.js
Last active December 8, 2020 14:59
Javascript Request Signature for Points.com using Postman
function randomString(len, charSet) {
charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var randomString = '';
for (var i = 0; i < len; i++) {
var randomPoz = Math.floor(Math.random() * charSet.length);
randomString += charSet.substring(randomPoz,randomPoz+1);
}
return randomString;
}
@leog
leog / Dockerfile
Last active February 1, 2019 17:19
LiquidFeedback v4.x Docker setup
FROM nickblah/lua:5.3 # debian:stretch with Lua5.3 pre-installed
# Components version
ENV POSTGRESQL_VERSION 9.6
ENV LF_CORE_VERSION 4.0.0
ENV MOONBRIDGE_VERSION 1.0.1
ENV WEBMCP_VERSION 2.1.0
ENV PGLATLON_VERSION 0.10
# Use baseimage-docker's init system.
@leog
leog / Dockerfile
Last active December 30, 2018 17:07
LiquidFeedback v3.x Docker setup
FROM debian
# Components version
ENV LF_CORE_VERSION 3.2.1
ENV LF_FRND_VERSION 3.2.1
ENV MOONBRIDGE_VERSION 1.0.1
ENV WEBMCP_VERSION 2.0.3
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]