Skip to content

Instantly share code, notes, and snippets.

View hosmelq's full-sized avatar
🎯
Focusing

Hosmel Quintana hosmelq

🎯
Focusing
View GitHub Profile
@hosmelq
hosmelq / machine.js
Last active December 14, 2019 01:05
Generated by XState Viz: https://xstate.js.org/viz
function buildVibrationPattern(seconds) {
return new Array(seconds / 1500)
.fill(null)
.reduce(prev => [...prev, 0, 1000, 500], [])
}
const ACTIVE = `active`
const BACKGROUND = `background`
const WAIT_TIME = 30000
const PATTERN = buildVibrationPattern(WAIT_TIME)
@hosmelq
hosmelq / machine.js
Created November 29, 2019 00:01
Generated by XState Viz: https://xstate.js.org/viz
function produce() {
return {}
}
const machine = new Machine(
{
id: `navigator`,
initial: `booting`,
context: {
courier: null
@hosmelq
hosmelq / machine.js
Last active November 29, 2019 00:00
Generated by XState Viz: https://xstate.js.org/viz
function produce() {
return {}
}
const machine = new Machine(
{
id: `navigator`,
initial: `booting`,
context: {
courier: null
@hosmelq
hosmelq / machine.js
Last active November 11, 2019 18:15
Generated by XState Viz: https://xstate.js.org/viz
// Yup schema
const validationSchema = {}
// immer
function produce() {
return {}
}
// run Yup validation
function runValidationSchema(values, schema) {
@hosmelq
hosmelq / machine.js
Last active November 11, 2019 18:11
Generated by XState Viz: https://xstate.js.org/viz
function produce() {
return {}
}
const machine = new Machine(
{
id: `text-input-machine`,
type: `parallel`,
context: {
errorMessage: null,
@hosmelq
hosmelq / machine.js
Last active November 1, 2019 15:56
Generated by XState Viz: https://xstate.js.org/viz
new Machine(
{
id: `signIn`,
initial: `ready`,
context: {
email: ``,
password: ``
},
states: {
ready: {
@hosmelq
hosmelq / machine.js
Last active October 9, 2019 23:21
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@hosmelq
hosmelq / nginx-tuning.md
Created November 12, 2018 22:17 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

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.

@hosmelq
hosmelq / lambda-at-edge.yaml
Created October 22, 2018 04:07 — forked from stu-smith/lambda-at-edge.yaml
Shows how to use CloudFormation to attach a Lambda@Edge function to a CloudFront distribution to add HSTS and CSP custom headers. NOTE: The stack must be updated twice: once with the condition set to false, and once with it set to true.
AWSTemplateFormatVersion: 2010-09-09
Parameters:
RootDomainName:
Type: String
IncludeLambdaEdge:
Type: String
AllowedValues: ['true', 'false']
Conditions:
IncludeLambdaEdge:
!Equals ['true', !Ref IncludeLambdaEdge]
@hosmelq
hosmelq / _Stay_standalone.md
Created June 29, 2017 16:44 — forked from irae/_Stay_standalone.md
Stay Standalone: Prevent links in standalone web apps opening Mobile Safari

#Stay Standalone

A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.