Skip to content

Instantly share code, notes, and snippets.

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

Shane Richards ShaneRich5

🏠
Working from home
  • FTI Consulting
  • New York, NY
View GitHub Profile
import React from 'react'
export default function useIntersectionObserver({
root,
target,
onIntersect,
threshold = 1.0,
rootMargin = '0px',
enabled = true,
}) {
const seconds = 1619798400
const date = new Date(1970, 0, 1) // Epoch
date.setSeconds(seconds)
@ShaneRich5
ShaneRich5 / register.dart
Created December 16, 2020 02:07
flutter sample
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class RegistrationScreen extends StatefulWidget {
static const routeName = '/register';
@override
State<StatefulWidget> createState() {
return _RegistrationState();
}
@ShaneRich5
ShaneRich5 / assignment_2.cpp
Created October 15, 2020 19:10
Assignment
#include <iostream>
using namespace std;
//enum Months { Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,Dec};
char skip;
char response;
int m = 0, d = 0, y = 0;
int OrdDay = 0, priorDays = 0;
bool IsLeapYear(int y, int priorDays)
@ShaneRich5
ShaneRich5 / test.ts
Created April 30, 2020 18:27
angular test
import { fakeAsync, tick } from '@angular/core/testing';
describe('brainstorming test', () => {
test('ngOnInit() should initiate autocomplete and its dataset', fakeAsync(() => {
// const mockedTemplateOptions = jest.fn() as any as FormlyTemplateOptions;
// component.to = mockedTemplateOptions;
// const mockedTemplateOptions = jest.spyOn(component.to, 'search').mockReturnValue('a');
@ShaneRich5
ShaneRich5 / basic_fib_checker.py
Created September 29, 2018 07:41
Fibonnaci Checker
def Fib_Checker(lst):
size = len(lst)
if size == 0:
return False
start = lst[0]
previous, current = 0, 1
if settings.TESTING:
import coverage
cov = coverage.coverage(source=['entities'], omit=['*/tests/*'])
cov.set_option('report:show_missing', True)
cov.erase()
cov.start()
execute_from_command_line(sys.argv)
@ShaneRich5
ShaneRich5 / bit_counting.py
Last active March 3, 2018 02:41
Code Wars
# Write a function that takes an (unsigned) integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
# Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
def countBits(n):
binary = bin(n)[2:]
return len(filter(lambda x: x == '1', binary))
# Alternative solution
# def countBits(n):
def sum_two(a, b):
return int(a) + int(b)
def compare_versions(version_a, version_b):
a = map(int, version_a.split('.'))
b = map(int, version_b.split('.'))
first_a, first_b = int(a[0]), int(b[0])
# check if a release number is greater
@ShaneRich5
ShaneRich5 / power_hungry.py
Last active November 1, 2017 01:43
Google's foo.bar challenges
def answer(xs):
negatives = []
result = 0
if len(xs) == 1:
return xs[0]
for element in xs:
if element > 0:
if result == 0: