This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Password Complexity Regex | |
| //Must be 8-40 characters | |
| //Must contain at least one digit | |
| //Must contain at least one lowercase letter | |
| //Must contain at least one uppercase letter | |
| //Must contain at least one special character | |
| var term = "Samp!e99"; | |
| var re = new RegExp( | |
| /^(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- use database | |
| USE [dbname] | |
| GO | |
| -- drop constraints | |
| DECLARE @DropConstraints NVARCHAR(max) = '' | |
| SELECT @DropConstraints += 'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' | |
| + QUOTENAME(OBJECT_NAME(parent_object_id)) + ' ' + 'DROP CONSTRAINT' + QUOTENAME(name) | |
| FROM sys.foreign_keys | |
| EXECUTE sp_executesql @DropConstraints; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select | |
| 'data source=' + @@servername + | |
| ';initial catalog=' + db_name() + | |
| case type_desc | |
| when 'WINDOWS_LOGIN' | |
| then ';trusted_connection=true' | |
| else | |
| ';user id=' + suser_name() | |
| end | |
| from sys.server_principals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Password complexity regex that has... | |
| //Must be 8-40 characters | |
| //Must contain at least one digit | |
| //Must contain at least one lowercase letter | |
| //Must contain at least one uppercase letter | |
| //Must contain at least one special character | |
| const password = "HelloHello$1"; | |
| const result = /((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,40})/.test( | |
| password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import jwt_decode from "jwt-decode"; | |
| export const isJwtExpired = (token) => { | |
| if (typeof token !== "string" || !token) | |
| throw new Error("Invalid token provided"); | |
| let isJwtExpired = false; | |
| const { exp } = jwt_decode(token); | |
| const currentTime = new Date().getTime() / 1000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private string CreateName(string requestedName, List<string> values) | |
| { | |
| string str = requestedName; | |
| string formattedName = str; | |
| int i = 0; | |
| while (values.Contains(formattedName)) | |
| { | |
| i++; | |
| formattedName = string.Format("{0} ({1})", str, i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export type ComponentProps = { | |
| foo?: boolean; | |
| bar: string; | |
| className?: string; | |
| }; | |
| export const Component = React.forwardRef( | |
| (props: ComponentProps, ref?: React.Ref<HTMLButtonElement>) => { | |
| const { className, foo, bar } = props; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ${ | |
| using Typewriter.Extensions.Types; | |
| using System.Text.RegularExpressions; | |
| using System.Diagnostics; | |
| string ToKebabCase(string typeName){ | |
| return Regex.Replace(typeName, "(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])","-$1", RegexOptions.Compiled) | |
| .Trim().ToLower(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState, useRef, useEffect } from "react"; | |
| export default function useFetchAll(urls) { | |
| const prevUrls = useRef([]); | |
| const [data, setData] = useState(null); | |
| const [loading, setLoading] = useState(true); | |
| const [error, setError] = useState(null); | |
| useEffect(() => { | |
| // Only run if the array of URLs passed in changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState, useRef, useEffect } from "react"; | |
| //check package.json -> start script -> cross-env | |
| const baseUrl = process.env.REACT_APP_API_BASE_URL; | |
| export default function useFetch(url) { | |
| const isMounted = useRef(false); | |
| const [data, setData] = useState(null); | |
| const [error, setError] = useState(null); | |
| const [loading, setLoading] = useState(true); |