Skip to content

Instantly share code, notes, and snippets.

View WillMayger's full-sized avatar

Will Mayger WillMayger

View GitHub Profile
@WillMayger
WillMayger / .vimrc
Last active November 24, 2022 16:10
vimrc
" TODO:
" 1. Follow instructions on https://github.com/junegunn/vim-plug.
" 2. Copy this file into your ~/.vimrc
" 3. Write the file
" 4. Run Command :PlugInstall
" 5. write & quit
" 6. To see the theme correctly you may need to adjust the terminal colours
"
" VIMRC BELOW:
" When started as "evim", evim.vim will already have done these settings, bail
// Script tag to include in <head>:
<script
type="text/javascript"
src="//maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_GOES_HERE&language=en&libraries=places"
></script>
import React, { useState, useEffect } from "react"
// Async google places autocomplete function
@WillMayger
WillMayger / using-componentdidmount-in-react-hooks.js
Last active November 19, 2020 09:06
Using componentDidMount in react hooks - Full article on componentDidMount with react hooks found here: https://atomizedobjects.com/blog/react/using-componentdidmount-in-react-hooks/
import { useEffect, useState, useRef, useCallback } from 'react'
// Solutions for the article https://atomizedobjects.com/blog/react/using-componentdidmount-in-react-hooks/
// about using componentDidMount in react hooks
export function SolutionsOneToFour() {
// Solution 1
useEffect(() => {
console.log("Mounted")
}, [])
@WillMayger
WillMayger / worker-fun.js
Last active November 7, 2019 23:00
worker searching using divide and conquer
// Uses divide and conquer to find the location of a range of date times within a large array of datetimes.
// It then uses this location to match the date on another array of the same order containing more information about the date.
/* eslint-disable */
const worker = () => {
function divideAndConquer(lookFor, data, len, order) {
const half = Math.floor(len - 1 / 2);
if (!data[half]) return -1;
if (data[half] === lookFor) return half;
@WillMayger
WillMayger / dynamic-imports-for-flags.js
Last active November 7, 2019 22:58
Dynamic import hook for flags
// @flow
import { useState, useEffect } from 'react'
// for dynamically importing all flags
export async function createFlagStore(ary: { node: { iso_country_code: string } }[] | any): Promise<Map<string, string>> {
const promises = ary.map(({ node: { iso_country_code } }) =>
import(`../static/images/flags/${iso_country_code.toLowerCase()}.png`)
.then((item) => ({
iso_country_code,
flag: item.default,
import { cred } from './cred';
var Horseman = require("node-horseman");
var cheerio = require('cheerio');
var PromisePool = require('es6-promise-pool');
export class Pod {
constructor(lessonsObj) {
var horseman = new Horseman();
this.horseman = horseman;
@WillMayger
WillMayger / Hello.java
Created February 23, 2016 14:38
Yoooo Gist
System.out.println("Hello World");