Skip to content

Instantly share code, notes, and snippets.

View leovolving's full-sized avatar

Leo Yockey leovolving

View GitHub Profile
@leovolving
leovolving / html-to-plain-text.js
Created April 18, 2023 19:30
Converts html string to plain text, adding a single whitespace between tags
// html string includes line break
const htmlString = "<h1 style=\"\">test</h1><p style=\"\">line</p><p style=\"\">break</p><p style=\"\">testing <strong>foo</strong> testing</p><ul><li><p style=\"\">this</p></li><li><p style=\"\">and this</p></li></ul>"
// creates a new html document
const htmlDom = new DOMParser().parseFromString(htmlString, 'text/html')
console.log(htmlDom.body.children) // HTMLCollection(5) [h1, p, p, p, ul]
const plainText = Array
.from(htmlDom.body.children, e => e.innerText) // map fn is 2nd argument in Array.from
@leovolving
leovolving / wnba_champions.js
Last active October 31, 2024 16:13
Array of WNBA champions, sorted by year
[
{ name: 'Houston Comets', year: 1997 },
{ name: 'Houston Comets', year: 1998 },
{ name: 'Houston Comets', year: 1999 },
{ name: 'Houston Comets', year: 2000 },
{ name: 'Los Angeles Sparks', year: 2001 },
{ name: 'Los Angeles Sparks', year: 2002 },
{ name: 'Detroit Shock', year: 2003 },
{ name: 'Seattle Storm', year: 2004 },
{ name: 'Sacramento Monarchs', year: 2005 },
@leovolving
leovolving / mlb-live-game-data.js
Created April 18, 2021 18:52
MLB Live Game Data Object
{
liveData: {
boxscore: {
teams: {
[home | away]: {
teamStats: {
pitching: {
strikeouts: Number
}
}
@leovolving
leovolving / a11y-emoji.html
Last active April 17, 2020 20:36
accessible HTML rendering of the clapping hand emoji
<span role="img" aria-label="clap">
<!-- unicode for clapping hand emoji -->
&#128079;
</span>
<!-- this is a valid js comment
--> and so is this
@leovolving
leovolving / GetRequest.swift
Created September 11, 2017 01:39
GET Request Using Swift
//A basic GET request using the Ron Swanson Quote API
// https://github.com/jamesseanwright/ron-swanson-quotes
let targetUrl = URL(string: "http://ron-swanson-quotes.herokuapp.com/v2/quotes")
let task = URLSession.shared.dataTask(with: targetUrl!) { (data, response, error) in
if error != nil {
print("ERROR!")
}
else {
if let content = data {
# prints 0-9
for x in range(10):
print x
# prints 1-10
for x in range(1, 11):
print x
# remember, we don't need to declare variables
# we can just assign them
def true_or_false(bool):
if bool == True:
return "This is a true statement!"
else:
return "This is a false statement!"
print true_or_false(False) # returns the else block
@leovolving
leovolving / generators.js
Created August 23, 2017 17:38
Basic JS Generator
//I typically use promise chains to handle
//sync control but today I'm playing around with generators.
//View on Repl: https://repl.it/KWdA/1
function *myGen() {
var one = yield 1;
var two = yield 2;
var three = yield 3;
console.log(one, two, three);
}
Get rid of GIFs and make it so that text truncates at line break or X characters
-Did a height w/ overflow control. Removed GIFs
vertically align image in bio and stop text at ~”in the form of”
-Vertical align of image not needed now that text has been shortened
Make links to repos and live site same size
-removed link borders