Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Tiffany White twhite96

🏠
Working from home
Block or report user

Report or block twhite96

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View package.json
{
"name": "new-post-gatsby-starter-blog",
"version": "1.1.5",
"description": "create a new post in gatsby starter blog format with a simple command",
"main": "/bin/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/twhite96/gatsby-starter-blog-new-post.git"
},
"bin": {
@twhite96
twhite96 / umount.js
Created Jan 5, 2019
Lifecycle Method
View umount.js
componentWillUnmount() {
clearInterval(this.timer);
}
View onclear-fix.js
handleOnClear = () => {
clearInterval(this.timer);
this.setState({
lapse: 0,
running: false
});
};
@twhite96
twhite96 / onclear.js
Last active Jan 5, 2019
handleOnClear method
View onclear.js
handleOnClear = () => {
this.setState({
lapse: 0,
running: false
});
};
View full-update-function.js
class StopWatch extends React.Component {
state = { lapse: 0, running: false };
handleRunClick = () => {
//updater function
this.setState(state => {
if (state.running) {
clearInterval(this.timer);
} else {
const startTime = Date.now() - this.state.lapse;
this.timer = setInterval(() => {
View updater-function.js
//updater function
this.setState(state => {
if (state.running) {
clearInterval(this.timer);
} else {
const startTime = Date.now() - this.state.lapse;
this.timer = setInterval(() => {
this.setState({
lapse: Date.now() - startTime
});
View no-method.js
class StopWatch extends React.Component {
state = { lapse: 0, running: false };
handleRunClick = () => {
const startTime = Date.now() - this.state.lapse;
setInterval(() => {
this.setState({
lapse: Date.now - startTime
});
});
this.setState({
@twhite96
twhite96 / Timer fallback.js
Created Nov 15, 2018 — forked from sw-yx/Timer fallback.js
Timer component for use as a Suspense fallback
View Timer fallback.js
function Timer() {
const startTime = React.useRef(performance.now());
const [time, setTime] = React.useState(performance.now());
React.useEffect(() => {
const id = setTimeout(() => {
ReactDOM.flushSync(() => {
setTime(performance.now());
});
}, 2);
View making-javascript-faster.md

Making Javascript faster

This is a list of guidelines to make your Javascript faster, often associated with jsPerf benchmarks.

Profile before optimizing

If you have an existing codebase, don't get carried away with premature optimizations. Profile to find the slow bits and pick the low hanging fruit.

Some of the latter lessons in Code School's Chrome DevTools course will teach you how to profile your code.

@twhite96
twhite96 / bs4.py
Created Oct 18, 2018 — forked from fffaraz/bs4.py
Python YouTube Playlist Link Collector
View bs4.py
from bs4 import BeautifulSoup
import requests
def getPlaylistLinks(url):
sourceCode = requests.get(url).text
soup = BeautifulSoup(sourceCode, 'html.parser')
domain = 'https://www.youtube.com'
for link in soup.find_all("a", {"dir": "ltr"}):
href = link.get('href')
if href.startswith('/watch?'):
You can’t perform that action at this time.