Skip to content

Instantly share code, notes, and snippets.

View jhackett1's full-sized avatar
🦁

Jaye Hackett jhackett1

🦁
View GitHub Profile
@jhackett1
jhackett1 / google-oauth.js
Created December 14, 2020 11:40
Using Google oAuth to authenticate a React app and Express API
////////////
// REACT APP
////////////
// Your login screen
<GoogleLogin
clientId={process.env.REACT_APP_GOOGLE_CLIENT_ID}
buttonText="Sign in with Google"
className="ct-button ct-button--secondary"
@jhackett1
jhackett1 / authContext.js
Created December 14, 2020 11:35
A React context showing how you might manage authentication
import React, { createContext, useContext } from "react"
import useSWR from "swr"
const AuthContext = createContext(false)
export const AuthProvider = (props) => {
const { data, error, mutate } = useSWR(`/api/v1/auth/me`)
const googleLogIn = async googleData => {
@jhackett1
jhackett1 / learn-sql-demo-db.sql
Last active December 10, 2020 15:46
demo postgresql database for learning sql
create table employees (
id SERIAL PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
email VARCHAR(50),
street_address VARCHAR(50),
postcode VARCHAR(50),
department VARCHAR(50),
currently_employed VARCHAR(50),
employed_from DATE,
@jhackett1
jhackett1 / functions.php
Last active January 28, 2021 19:04
wp-geo-search example template usage
<?php
// Make WP recognise the extra query parameter
function example_query_vars( $qvars ) {
$qvars[] = 'location';
return $qvars;
}
add_filter( 'query_vars', 'example_query_vars' );
@jhackett1
jhackett1 / query.sql
Created May 24, 2019 20:42
bucks-community-assets-export
SELECT ASSETS.[Asset ID], ASSETS.[GET category], ASSETS.KeyWords, ASSETS.ACMD, ASSETS.CR, ASSETS.DO, ASSETS.EL, ASSETS.SG, ASSETS.SCG, ASSETS.SA, ASSETS.YPA, ASSETS.[Local Area], ASSETS.Area, ASSETS.Organisation, ASSETS.Meeting, ASSETS.MO, ASSETS.TU, ASSETS.WE, ASSETS.TH, ASSETS.FR, ASSETS.ST, ASSETS.SU, ASSETS.DaytimeMeetings, ASSETS.[Time-Date], ASSETS.Venue, ASSETS.Postcode, ASSETS.Cost, ASSETS.ContactName, ASSETS.ContactNo, ASSETS.Website, ASSETS.ContactEmail, ASSETS.Description, ASSETS.[Last-Updated], ASSETS.ReviewDate, ASSETS.[Status-of-Review], ASSETS.[Review Notes], ASSETS.Assigned, ASSETS.ReviewNumber, [Page 2].[Age YP], [Page 2].[Age YA], [Page 2].[Age OA], [Page 2].[Local Area], [Page 2].[LAF GAyl], [Page 2].[LAF Wadd], [Page 2].[LAF C&CV], [Page 2].[LAF Beec], [Page 2].[LAF W&D], [Page 2].[LAF NWC], [Page 2].[LAF GBWI], [Page 2].[LAF H&LC], [Page 2].[LAF SWC&M], [Page 2].[LAF Amer], [Page 2].[LAF Buck], [Page 2].[LAF HW], [Page 2].[LAF W&I], [Page 2].[LAF CWV], [Page 2].[LAF Chal], [Page 2].[LAF W
@jhackett1
jhackett1 / bookmarklet.js
Last active April 7, 2019 09:45
Hide popups and make the page scrollable again
var elements = document.querySelectorAll('body *')
for (i = 0; i < elements.length; i++) {
if (getComputedStyle(elements[i]).position === 'fixed') elements[i].parentNode.removeChild(elements[i])
}
document.querySelector('body').setAttribute('style', 'overflow-y:scroll !important');
document.querySelector('html').setAttribute('style', 'overflow-y:scroll !important');
@jhackett1
jhackett1 / forTest.js
Last active December 20, 2017 13:13
A function just crying out for a unit test
// This function should return a user object. Does it?
module.exports.getUser = function(){
var user = {
firstName: "Dave",
lastName: "Bowman",
occupation: "Astronaut",
admin: false
}
return;
@jhackett1
jhackett1 / async.js
Last active January 5, 2018 14:44
A simple blocking function, used for async exercises
// A function which returns an object after one second
var getData = function(cb){
setTimeout(function(){
var data = {
data: "Some data",
moreData: "And more data",
lastData: true
}
cb(data)
}, 1000)