Skip to content

Instantly share code, notes, and snippets.

View loraxx753's full-sized avatar

Kevin Baugh loraxx753

View GitHub Profile
@loraxx753
loraxx753 / console.text
Last active March 14, 2019 02:25
Go to this page https://en.wikipedia.org/wiki/Electron, open the console, paste this in
(function() {
console.clear()
const response = {}
const values = [ ...document.querySelectorAll('.infobox td') ].slice(1).map(el => el.innerText)
;[ ...document.querySelectorAll('.infobox th') ].map(el => el.innerText).map(keyText => {
response[keyText.replace(/\s/g, '_').toLowerCase()] = values.shift()
})
return { ...response}
})()
const data = [
[1,2,3,4,5],
[6,7,8,9,10]
]
function* getNumbers() {
for(let idx in data) {
for(let subIdx in data[idx]) {
yield data[idx][subIdx]
export const getInput = () => new Promise((resolve, reject) => {
document.querySelector('form').addEventListener('submit', function listener(e) {
e.preventDefault()
const inputString = e.target.querySelector('input[type=text]').value
resolve(inputString)
e.target.removeEventListener('submit', listener)
})
})
/* USAGE
@loraxx753
loraxx753 / sound-synth.js
Created February 6, 2019 17:24
File for playing mp3's or using speech synthesis
/** USAGE
import { speak, createSound } from './synth.js';
(async () => {
document.querySelector('button[start-static]').addEventListener('click', () => {
const sound = createSound("a.mp3");
sound.play()
})
@loraxx753
loraxx753 / pixelColor.js
Last active December 31, 2018 18:00
Grabs the color of an individual pixel in the image with the source '_assets/data/example.png'
(async () => {
const img = document.createElement('img')
img.src = "_assets/data/example.png"
img.onload = () => {
document.body.appendChild(img)
const canvas = document.createElement('canvas')
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
document.body.removeChild(img)
@loraxx753
loraxx753 / legacy-browser-polyfills.js
Created November 12, 2018 18:36
Polyfills that will conditionally load based on whether a browser supports promises or not.
const script = document.createElement('script');
const link = document.createElement('link');
function appendThisScriptToTheBodyTag(src, callback, options) {
// Explicitly set the defaults for any optional parameters of the function
options = (options) ? options : new Object()
callback = (callback) ? callback : new Function()
const scriptClone = script.cloneNode(true);
// Reference: https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode
@loraxx753
loraxx753 / theme.css
Created November 7, 2018 00:11
Theme for HTML Template
@import url('https://fonts.googleapis.com/css?family=Raleway|Raleway+Dots|Roboto+Slab');
:root {
--color-navy: #001F3F;
--color-blue: #0074D9;
--color-aqua: #7FDBFF;
--color-teal: #39CCCC;
--color-olive: #3D9970;
--color-green: #2ECC40;
--color-lime: #01FF70;--color-yellow: #FFDC00;
import React from 'react'
import { Deck, Slide, Text } from 'spectacle'
const FirstSlide = props => {
return (
<Slide>
<Text>Hello there {props.key}.</Text>
<Text>Ready?</Text>
</Slide>
)
import React, { Component } from "react";
import firebase from "../firebase.js";
const FirebasePromise = props => {
return props.children("testing, 1 2 3");
};
// firebase
// .storage()
// .ref()
import React from "react";
import firebase from "../firebase.js";
const FiebasePromise = props => firebase
.storage()
.ref()
.child("images/" + props.imageName)
.getDownloadURL()
};