Skip to content

Instantly share code, notes, and snippets.

@arekbartnik
arekbartnik / create_pr.sh
Created September 14, 2024 13:31 — forked from slavingia/create_pr.sh
Create a (draft) pull request using GitHub CLI
#!/bin/bash
# Create a (draft) pull request using GitHub CLI.
# It assigns the PR to the current user, fills in the title from the first commit,
# and uses the PR template file for the description.
set -euo pipefail
# Colors for output
RED='\033[0;31m'
@arekbartnik
arekbartnik / useMagicalMutation.ts
Created June 27, 2023 13:34 — forked from kitze/useMagicalMutation.ts
magical mutation for blitz
import { useToast } from "@chakra-ui/react";
import { exists } from "app/core/utils/js-utils";
import { QueryFn, useMutation } from "blitz";
import { MutationOptions } from "react-query";
type ShowLoginOnFailFn = (s: any) => boolean;
type CustomOptions = {
errorMessage?: string;
showLoginOnFail?: boolean | ShowLoginOnFailFn;
@arekbartnik
arekbartnik / tailwind-plugin-patcher.py
Created January 24, 2023 19:02 — forked from liautaud/tailwind-plugin-patcher.py
Small Python script to patch the IntelliJ TailwindCSS plugin.
import re
from zipfile import ZipFile, Path
"""
TailwindCSS plugin patcher for IntelliJ IDEA
--------------------------------------------
1. Download the latest ZIP of the plugin compatible with your version of IntelliJ here:
https://plugins.jetbrains.com/plugin/15321-tailwind-css/versions
2. Fill `CLASS_ATTRIBUTES` to specify which XML attributes can contain Tailwind classes.
@arekbartnik
arekbartnik / InternalLink.tsx
Created July 19, 2022 07:42 — forked from tomhicks/InternalLink.tsx
Strongly-typed NextJS internal links
@arekbartnik
arekbartnik / encrypt.js
Created April 14, 2021 12:02 — forked from shahinghasemi/encrypt.js
FullStack AES-GCM Encryption Decryption using NodeJS and Browser standard libraries (native crypto API)
//----------------------------------------------------------------
// ------------------- ServerSide(NODE.JS) -------------------
//----------------------------------------------------------------
function encrypt(message){
const KEY = crypto.randomBytes(32)
const IV = crypto.randomBytes(16)
const ALGORITHM = 'aes-256-gcm';
const cipher = crypto.createCipheriv(ALGORITHM, KEY, IV);
let encrypted = cipher.update(message, 'utf8', 'hex');
@arekbartnik
arekbartnik / README.md
Created February 25, 2021 16:56 — forked from tannerlinsley/README.md
Replacing Create React App with the Next.js CLI

Replacing Create React App with the Next.js CLI

How dare you make a jab at Create React App!?

Firstly, Create React App is good. But it's a very rigid CLI, primarily designed for projects that require very little to no configuration. This makes it great for beginners and simple projects but unfortunately, this means that it's pretty non-extensible. Despite the involvement from big names and a ton of great devs, it has left me wanting a much better developer experience with a lot more polish when it comes to hot reloading, babel configuration, webpack configuration, etc. It's definitely simple and good, but not amazing.

Now, compare that experience to Next.js which for starters has a much larger team behind it provided by a world-class company (Vercel) who are all financially dedicated to making it the best DX you could imagine to build any React application. Next.js is the 💣-diggity. It has amazing docs, great support, can grow with your requirements into SSR or static site generation, etc.

So why

(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@arekbartnik
arekbartnik / whatev.js
Created August 25, 2020 21:07 — forked from Jayphen/whatev.js
Page tracking in Sapper
// stores/location.ts
import { writable, derived } from "svelte/store";
import { beforeUpdate } from "svelte";
export interface LocationStore {
current: Location | undefined;
previous: Location | undefined;
}
////////////////////////////////////////////////////////////////////////////////
// Create a directory called "pages" next to
// this file, put markdown files in there, and
// then run:
//
// ```
// $ node build.mjs
// ```
//
// Then deploy the "build" directory somewhere.
const glob = require("glob");
const fs = require("fs");
const path = require("path");
const { PurgeCSS } = require("purgecss");
const cssnano = require("cssnano");
const cheerio = require("cheerio");
const minify = require("html-minifier").minify;
const sharp = require("sharp");
// This runs on Netlify after Jekyll builds a full site.