This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
function useFetch({ onSuccess, onError }) { | |
const [data, setData] = useState(null); | |
const [loading, setLoading] = useState(false); | |
const [error, setError] = useState(null); | |
const handleFetch = async (url, options = {}) => { | |
setLoading(true); | |
setError(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"image" | |
"image/png" | |
"io/ioutil" | |
"os" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createElement(tag, attrs, ...children) { | |
// Custom Components will be functions | |
if (typeof tag === 'function') { return tag() } | |
// regular html tags will be strings to create the elements | |
if (typeof tag === 'string') { | |
// fragments to append multiple children to the initial node | |
const fragments = document.createDocumentFragment() | |
const element = document.createElement(tag) | |
children.forEach(child => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"BlackBerry Z30": { | |
"width": 360, | |
"height": 640 | |
}, | |
"BlackBerry PlayBook": { | |
"width": 600, | |
"height": 1040 | |
}, | |
"Galaxy Note 3": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"3x4K:12K gaming PC": { | |
"designation": "12K", | |
"width": "11520", | |
"height": "2160", | |
"total-pixels": "24,883,200", | |
"aspect-ratio": { | |
"storage": "11520:2160", | |
"display": "48:9", | |
"pixel": "5.333" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import './Card.css' | |
function Item(props) { | |
let value | |
if (Array.isArray(props.value)) { | |
value = props.value.map(n => <span key={n}>{n}</span>) | |
} else { | |
value = <span>{props.value}</span> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns array with existing delimiters | |
function parseText(text){ | |
const reg1 = /(?<=\[name\]|\[age\])/g // negative lookahead | |
const reg2 = /(?=\[name\]|\[age\])/g // positive lookahead | |
return(Array.prototype.concat.apply([], (text.split(reg1).map(m => m.split(reg2))))) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--...--> | |
<!doctype > | |
<a></a> | |
<abbr></abbr> | |
<acronym></acronym> | |
<address></address> | |
<applet></applet> | |
<area></area> | |
<article></article> | |
<aside></aside> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Messages } from "./templates/Messages"; | |
import { SendForm } from "./templates/SendForm"; | |
import { scrollbarFunctions, textareaFunctions, generateFunctions, getDom } from "../js/custom.js" | |
import '../css/app.css'; | |
export default class App extends Component { | |
constructor() { | |
super() | |
this.state = { |