Skip to content

Instantly share code, notes, and snippets.

View alenthomas's full-sized avatar
🏠
Working from home

Alen Thomas alenthomas

🏠
Working from home
View GitHub Profile
@alenthomas
alenthomas / delaunayCalculation.js
Last active November 9, 2020 10:47
delaunay point calculation
const calculateDelaunayPoints = (data, width, height, n) => {
// Initialize the variables
const pointsInput = new Float64Array(n * 2);
const centroid = new Float64Array(n * 2);
const stippling = new Float64Array(n);
// Initialize the pointsInput using rejection sampling.
for (let i = 0; i < n; ++i) {
for (let j = 0; j < 30; ++j) {
@alenthomas
alenthomas / customCheckbox.css
Created August 7, 2019 06:15
Custom css styling for input type checkbox
input[type='checkbox'] {
outline: none !important;
padding: 0;
margin: 4px 0 0;
line-height: normal;
border: none;
-webkit-appearance: none;
appearance: none;
cursor: pointer;
}
@keyframes scroll {
0% { transform: translateY(0%); }
100% { transform: translateY(-200%); }
}
.parent {
overflow: hidden;
position: relative;
}
.one {
position: absolute;
import React, { Component } from 'react';
import 'intersection-observer'; // optional polyfill
import Observer from '@researchgate/react-intersection-observer';
import ReactResizeDetector from 'react-resize-detector';
import './styles.scss';
let data = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
let heights = [184,58,96,144,68,98,150,200,240];
@alenthomas
alenthomas / array-reduce.js
Created March 29, 2019 04:03
1d-array to 2d-array with reduce
let postObject = posts.reverse().reduce((acc, ele) => {
if(acc.s > 0) {
return {arr: [ele, ...acc.arr], rows: acc.rows, s: acc.s-1}
} else {
return {arr: [ele], rows: [acc.arr, ...acc.rows], s: 2};
}
}, {arr: [], rows: [], s: 3});
let rows = [[...postObject.arr], ...postObject.rows ];
import React, { Component } from 'react';
import { BrowserRouter, Route } from 'react-router-dom';
import { Security, ImplicitCallback } from '@okta/okta-react';
import { OktaAuthComponent, OktaLogout } from './OktaAuthComponent.js'
const config = {
issuer: 'https://*****.oktapreview.com/oauth2/default', // replace this with your okta dev url
redirect_uri: window.location.origin + '/implicit/callback',
client_id: '****' // replace this with your okta client_id
}
// src/OktaAuthComponent.js
import React, { Component } from 'react';
import { Redirect } from 'react-router-dom';
import { withAuth } from '@okta/okta-react';
export const OktaAuthComponent = withAuth(class Auth extends Component {
constructor(props) {
super(props);
this.state = { authenticated: null };
this.checkAuthentication = this.checkAuthentication.bind(this);
this.checkAuthentication();
@alenthomas
alenthomas / App.js
Last active September 17, 2018 18:27
import React, { Component } from 'react';
import { BrowserRouter, Route } from 'react-router-dom';
import { Security, ImplicitCallback } from '@okta/okta-react';
import { OktaAuthComponent, OktaLogout } from './OktaAuthComponent.js'
const config = {
issuer: 'https://*****.oktapreview.com/oauth2/default', // replace this with your okta dev url
redirect_uri: window.location.origin + '/implicit/callback',
client_id: '****' // replace this with your okta client_id
}
// src/OktaAuthComponent.js
import React, { Component } from 'react';
import { Redirect } from 'react-router-dom';
import { withAuth } from '@okta/okta-react';
export const OktaAuthComponent = withAuth(class Auth extends Component {
constructor(props) {
super(props);
this.state = { authenticated: null };
this.checkAuthentication = this.checkAuthentication.bind(this);
this.checkAuthentication();
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="demo"></div>
<button onclick="start();">Start</button>