Skip to content

Instantly share code, notes, and snippets.

View codeBelt's full-sized avatar
💭
I may be slow to respond.

Robert S. codeBelt

💭
I may be slow to respond.
View GitHub Profile
@ChrisDobby
ChrisDobby / canvasDraw.jsx
Last active March 9, 2023 09:23
React component to redraw a canvas when resized
import React from "react";
const scaleWidth = 500;
const scaleHeight = 500;
function draw(canvas, scaleX, scaleY) {
const context = canvas.getContext("2d");
context.scale(scaleX, scaleY);
context.clearRect(0, 0, canvas.clientWidth, canvas.clientHeight);
@ChrisDobby
ChrisDobby / widthAndHeight.jsx
Created July 28, 2019 13:06
React component to display the width and height of the window
import React from "react";
function WidthAndHeight() {
const [width, setWidth] = React.useState(window.innerWidth);
const [height, setHeight] = React.useState(window.innerHeight);
React.useEffect(() => {
window.addEventListener("resize", updateWidthAndHeight);
return () => window.removeEventListener("resize", updateWidthAndHeight);
});
@mehmetnyarar
mehmetnyarar / next-routes.md
Last active January 22, 2021 14:14
NextJS with Custom Routes (forked from [next-routes](https://github.com/fridays/next-routes))

NextJS with Custom Routes (next-routes.tsx)

<project_root>/src/routes/types.ts:

export interface IRoute {
  name: string
  page: string
  pattern: string
}
validationSchema: yup.object().shape({
firstName: yup.string().required(validationMessages.firstName),
lastName: yup.string().required(validationMessages.lastName),
emailAddress: yup
.string()
.email(validationMessages.email)
.test('eitherOr', validationMessages.eitherEmail, function(emailAddress) {
// tslint:disable-next-line:no-invalid-this
return Boolean(emailAddress) || Boolean(this.parent.pin);
}),
import { Component, OnInit } from '@angular/core';
import {FormGroup, FormBuilder} from '@angular/forms';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.scss' ]
})
export class AppComponent implements OnInit {
checkoutForm: FormGroup;
@markerikson
markerikson / NotificationManager.jsx
Created January 21, 2018 15:43
React / Redux / Semantic-UI toast notifications implementation
import React, {Component} from "react";
import {connect} from "react-redux";
import _ from "lodash";
import { Message } from "semantic-ui-react";
import {Portal} from 'react-portal';
import {selectNotifications} from "./notificationSelectors";
import {dismissNotification} from "./notificationActions";
@mir4ef
mir4ef / deep-merge.ts
Created January 9, 2018 03:14
Deep merging of JavaScript objects (in TypeScript)
interface IIsObject {
(item: any): boolean;
}
interface IObject {
[key: string]: any;
}
interface IDeepMerge {
(target: IObject, ...sources: Array<IObject>): IObject;
/**
* https://github.com/acdlite/flux-standard-action
*/
export interface IAction<T> {
type: string;
payload?: T;
error?: boolean;
meta?: any;
}
@rambabusaravanan
rambabusaravanan / README.md
Last active March 6, 2021 13:37
GitLab CI Configuration YAML

Firebase Deployment

Step 1: Get Token

Generate the firebase token from your terminal using the command $ firebase login:ci

Waiting for authentication...

✔ Success! Use this token to login on a CI server:

1/VXXXXXXX--YOUR-FIREBASE-CI-TOKEN--XXXXXh92o

@ccheney
ccheney / hash-timestamp.js
Created October 26, 2017 15:51
generate hash+timestamp string & validate hash+timestamp string from userland
/**
* generate hash+timestamp string
* validate hash+timestamp string from userland
*/
const crypto = require('crypto');
const SECRET = ' ';
function _generateHash(isoDateString) {
return crypto