Skip to content

Instantly share code, notes, and snippets.

View mike667's full-sized avatar

Michael mike667

View GitHub Profile
@TonyGravagno
TonyGravagno / zodDefaultInstance.ts
Last active March 21, 2024 09:31
Create a default object from a Zod schema
import { z } from 'zod'
/**
* @summary Function returns default object from Zod schema
* @version 23.05.15.2
* @link https://gist.github.com/TonyGravagno/2b744ceb99e415c4b53e8b35b309c29c
* @author Jacob Weisenburger, Josh Andromidas, Thomas Moiluiavon, Tony Gravagno
* @param schema z.object schema definition
* @param options Optional object, see Example for details
* @returns Object of type schema with defaults for all fields
@chaance
chaance / use-prompt.jsx
Last active December 6, 2023 12:51
Example implementation of `usePrompt` and React Router v5's `<Prompt>` with `unstable_useBlocker`
/**
* ------------------------------------------------------------------------------
* IMPORTANT UPDATE:
* This is *not* a complete implementation and I do not suggest using it!. This
* was primarily an experiment to determine whether or not a decent blocking
* hook could be implemented in userland, and the answer we came up with is NO.
*
* Luckily we added `usePrompt` (behind an `unstable_` flag) back to React Router
* a few versions ago! It's not documented [and I'm no longer on the team, so I
* probably won't try to do anything about that], but you can see it in source.
@aliartiza75
aliartiza75 / minio_mc.sh
Last active August 11, 2023 16:53
Command to use mini/mc with minio server
# Step 1 : Start minio server with non-persistent data storage policy
#
# Description: -p 9000:9000: Minio server runs on port 9000 inside the docker container, -e 9000:9000 command is exposing the internal port on
# on external port.
#
# -e "MINIO_ACCESS_KEY=access_key": It sets an envrionment variable inside container named as MINIO_ACCESS_KEY
# with the value provided by user. It will be used when a user wants to access
# minio server
#
# -e "MINIO_SECRET_KEY=access_key_secret": It sets an envrionment variable inside container named as MINIO_SECRET_KEY
@AndrewPix
AndrewPix / serializers.py
Last active January 3, 2024 14:23
Integrate django-rest-knox with django-rest-auth
from rest_framework import serializers
from rest_auth.serializers import UserDetailsSerializer
class KnoxSerializer(serializers.Serializer):
"""
Serializer for Knox authentication.
"""
token = serializers.CharField()
@denji
denji / nginx-tuning.md
Last active May 21, 2024 18:18
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@joshbeckman
joshbeckman / animatedScrollTo.js
Created September 30, 2013 14:51
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;