Skip to content

Instantly share code, notes, and snippets.

@coyksdev
coyksdev / useGesture.ts
Created February 9, 2024 01:27 — forked from KristofferEriksson/useGesture.ts
A custom React Typescript hook for advanced touch gestures in UI
import { useEffect, useRef } from "react";
type GestureType =
| "swipeUp"
| "swipeDown"
| "swipeLeft"
| "swipeRight"
| "tap"
| "pinch"
| "zoom";
@coyksdev
coyksdev / triple_des.rs
Created September 27, 2022 05:41 — forked from vincascm/triple_des.rs
triple des(3des) ecb pkcs5 padding encrypt/decrypt function for rust, use openssl crypto library.
//! triple des(3des) ecb pkcs5 padding encrypt/decrypt function for rust, use openssl crypto
//! library.
//! refer to <http://blog.csdn.net/lyjinger/article/details/1722570>
//! coded by vinoca.
//! 2017.11.24
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
extern crate libc;
@coyksdev
coyksdev / AuthConstruct.ts
Last active November 7, 2021 07:10
sst cognito custom domain
import * as cdk from '@aws-cdk/core';
import * as cognito from '@aws-cdk/aws-cognito';
import * as route53 from '@aws-cdk/aws-route53';
import * as route53Targets from '@aws-cdk/aws-route53-targets';
import * as acm from '@aws-cdk/aws-certificatemanager';
import { RemovalPolicy } from "@aws-cdk/core";
import { Auth } from '@serverless-stack/resources';
type AuthConstructProps = cdk.StackProps & {
hostedZoneRootRecord: route53.ARecord;
@coyksdev
coyksdev / pre-signup.ts
Created September 29, 2021 23:44 — forked from onhate/pre-signup.ts
Merge AWS Cognito External Provider User with Cognito User on Pre SignUp
import { PreSignUpTriggerEvent, PreSignUpTriggerHandler } from 'aws-lambda';
import { CognitoIdentityServiceProvider } from 'aws-sdk';
const providerName = {
google: 'Google',
facebook: 'Facebook'
};
const tryMergeUserAccounts = async (event: PreSignUpTriggerEvent) => {
const { userPoolId, userName } = event;
@coyksdev
coyksdev / strong-password-regex.md
Created June 7, 2021 13:01 — forked from arielweinberger/strong-password-regex.md
Strong password Regular Expression - NestJS Course
  • Passwords will contain at least 1 upper case letter
  • Passwords will contain at least 1 lower case letter
  • Passwords will contain at least 1 number or special character
  • There is no length validation (min, max) in this regex!

Regular expression for JavaScript:

/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
@coyksdev
coyksdev / split_bar.dart
Created October 10, 2020 15:22 — forked from slightfoot/split_bar.dart
Split Bar in Flutter. Lets you touch between two horizontal sections to resize the split point.
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
void main() {
runApp(
MaterialApp(
theme: ThemeData(
primaryColor: Colors.indigo,
accentColor: Colors.pinkAccent,
),
@coyksdev
coyksdev / sessions.md
Created June 3, 2019 07:16 — forked from joepie91/sessions.md
Introduction to sessions

While a lot of Node.js guides recommend using JWT as an alternative to session cookies (sometimes even mistakenly calling it "more secure than cookies"), this is a terrible idea. JWTs are absolutely not a secure way to deal with user authentication/sessions, and this article goes into more detail about that.

Secure user authentication requires the use of session cookies.

Cookies are small key/value pairs that are usually sent by a server, and stored on the client (often a browser). The client then sends this key/value pair back with every request, in a HTTP header. This way, unique clients can be identified between requests, and client-side settings can be stored and used by the server.

Session cookies are cookies containing a unique session ID that is generated by the server. This session ID is used by the server to identify the client whenever it makes a request, and to associate session data with that request.

*S