Skip to content

Instantly share code, notes, and snippets.

@nfantone
nfantone / use-validation-schema.js
Last active December 4, 2023 10:27
Use `yup` with `react-final-form`
import { setIn } from 'final-form';
import { useMemo } from 'react';
/**
* Sets the `innerError.message` in an `errors` object at the key
* defined by `innerError.path`.
* @param {Object} errors The object to set the error in.
* @param {{ path: string, message: string }} innerError A `yup` field error.
* @returns {Object} The result of setting the new error message onto `errors`.
*/
@manzoorwanijk
manzoorwanijk / yup-with-final-form.js
Last active August 31, 2023 20:16
How to properly use yup validation schema with (React) Final Form?
import * as yup from 'yup';
import { setIn } from 'final-form';
const validationSchema = yup.object({
email: yup.string().email(),
shipping: yup.object({
name: yup.string(),
phone: yup.object({
code: yup.string().matches(/^\+\d+$/i),
number: yup.number().max(10),
@miguelmota
miguelmota / rsa_util.go
Last active April 21, 2024 15:10
Golang RSA encrypt and decrypt example
package ciphers
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"log"
)
@marcanuy
marcanuy / gist:06cb00bc36033cd12875
Created July 11, 2015 13:35
The 5,000 Most Frequently Used Domain Name Prefixes and Suffixes
1. my+ 1001. se+ 2001. thedaily+ 3001. empire+ 4001. herb+
2. +online 1002. test+ 2002. giant+ 3002. +cook 4002. +teen
3. the+ 1003. fish+ 2003. survey+ 3003. +deluxe 4003. affordable+
4. +web 1004. hk+ 2004. +conference 3004. +crunch 4004. proto+
5. +media 1005. florida+ 2005. twit+ 3005. michigan+ 4005. +ity
6. web+ 1006. fine+ 2006. pick+ 3006. cars+ 4006. myhome+
7. +world 1007. loan+ 2007. +dvd 3007. +forest 4007. plastic+
8. +net 1008. page+ 2008. cinema+ 3008. yacht+ 4008. +kc
9. go+ 1009. fox+ 2009. desi+ 3009. +wallet 4009. +foot
10. +group 1010. +gift 2010. act+ 3010. +contest 4010. +sup
@Yawning
Yawning / orhttp_example.go
Created April 29, 2015 14:41
How to dispatch HTTP requests via Tor in Go.
// To the extent possible under law, the Yawning Angel has waived all copyright
// and related or neighboring rights to orhttp_example, using the creative
// commons "cc0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package main
import (
// Things needed by the actual interface.
"golang.org/x/net/proxy"
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active February 25, 2024 13:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results