Skip to content

Instantly share code, notes, and snippets.

View pedropalhari's full-sized avatar

Pedro Palhari pedropalhari

View GitHub Profile
@pedropalhari
pedropalhari / vercel.env.d.ts
Created June 13, 2023 23:38
A gist containing all System Environment Variables from Vercel in `.d.ts` form so it can be used from a TypeScript deployed project
/**
* For more info on this variables, please check System Environment Variables on Vercel:
*
* https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables#system-environment-variables
*
* - Palhari, 2023/6/13
*/
declare namespace NodeJS {
export interface ProcessEnv {
@pedropalhari
pedropalhari / gist:a2d7d046207a5f059c1bd4e1eb4735fe
Last active September 9, 2022 20:35 — forked from mkocikowski/gist:aeca878d58d313e902bb
Setting up Redis to run as a daemon under systemd

This can be used to daemonize anything that would normally run in the foreground; I picked Redis. Put this in /etc/systemd/system/redis.service:

[Unit]
Description=Redis
After=syslog.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
RestartSec=5s
@pedropalhari
pedropalhari / create_postgresql_user.txt
Created July 22, 2022 02:42
Create PostgreSQL user - without trial and error.
- Go to the postgres user
$ sudo su postgres
- Execute create user
$ createuser --interactive <user>
- Change it's password inside postgres
$ psql
$ ALTER USER <user> WITH PASSWORD '<password>';
@pedropalhari
pedropalhari / miab-forward-all-spam.txt
Last active May 12, 2022 20:03
Disabe mail-in-a-box SPAM. Making all emails go to the inbox.
- Modify the SpamAssassin file
$ nano /etc/spamassassin/local.cf
- Add all domains as whitelisted from SpamAssassin, anywhere on the file
whitelist_from *@*
- Disable postgrey by creating a new .local file with whitelists and whitelisting every domain
$ nano /etc/postgrey/whitelist_clients.local
- Anywhere on the file
@pedropalhari
pedropalhari / nexus-utils.ts
Last active January 28, 2022 18:10
Nexus GraphQL `commonType` utility. To define fields to be shared.
import { InputDefinitionBlock, OutputDefinitionBlock } from "nexus/dist/blocks";
type TType<T extends string> =
| InputDefinitionBlock<T>
| OutputDefinitionBlock<T>;
// Type for the definition.
type CommonTypeDefinitionFunction = <T extends string>(
t: InputDefinitionBlock<T>
) => void;
@pedropalhari
pedropalhari / sane-next.json
Created July 2, 2021 09:56
Two commands that MUST be there on every Next.js project I do
{
"dev": "concurrently -c green.bold,blue.bold -n NEXT,TSC \"npm run dev-next\" \"npm run dev-tsc\"",
"dev-next": "next dev",
"dev-tsc": "tsc --noEmit --watch --preserveWatchOutput",
"build": "rimraf ./.next && next build && next export"
}
{
"application/vnd.lotus-1-2-3": [".123"],
"text/vnd.in3d.3dml": [".3dml"],
"video/3gpp2": [".3g2"],
"video/3gpp": [".3gp"],
"application/octet-stream": [
".a",
".bin",
".bpk",
".deploy",
@pedropalhari
pedropalhari / bash.js
Created May 26, 2021 03:59
bash helper for linux shell scripts
const { execSync } = require("child_process");
function bash(template, ...substitutions) {
let command = String.raw(template, substitutions);
let out = execSync(command);
return out.toString();
}
@pedropalhari
pedropalhari / afetch.ts
Last active May 24, 2021 15:14
A(uthorized) Fetch used for fast prototyping. We need only `{ error: boolean; message: string }` if there's an error on the API.
// a(uthorized)fetch
function getAccessToken() {
return localStorage.getItem("@project/accessToken");
}
function setAccessToken(token: string) {
localStorage.setItem("@project/accessToken", token);
}
@pedropalhari
pedropalhari / .bashrc
Created May 5, 2021 18:01
Node.js with Typescript without the massive ts-node overhead
#export NODE_PATH=/home/pedro/.nvm/versions/node/v14.16.0/lib/node_modules
export NODE_PATH=
alias tnode="node -r @swc-node/register"