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, { useState, useEffect } from "react"; | |
type NativeEventInputType = | |
| "insertText" | |
| "deleteContentBackward" | |
| "insertFromPaste" | |
| "formatBold" | |
| "deleteByCut"; | |
function isNativeEventTyping(inputType: NativeEventInputType) { |
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
interface InvestmentPeriod { | |
periodNumber: number; | |
startingBalance: number; | |
additionalInvestment: number; | |
periodInterest: number; | |
endingBalance: number; | |
} | |
interface CompoundResult { | |
startingBalance: number; |
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 type { AtomEffect } from "recoil"; | |
import qs from "query-string"; | |
import { atomDefaults } from "./defaults"; // Contain some default values e.g. { foo: 12, bar: 'hello' } | |
// In this example, we opt to store some state in the URL as raw params, and the rest as a base64 encoded string in the special `state` param | |
// e.g. http://localhost:3000?foo=12&bar=hello&state=<base 64 string of some other values> | |
const IS_BROWSER = typeof window !== "undefined"; | |
const getWindowSearchLocation = () => { |
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 type { AtomEffect } from 'recoil' | |
import qs from 'query-string' | |
import { atomDefaults } from './defaults' | |
const getStateFromUrl = () => { | |
return qs.parse(window.location.search, { | |
parseBooleans: true, | |
parseNumbers: true, | |
}) | |
} |
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
// String.prototype.padStart + String.prototype.padEnd (ES2017) | |
function stringPadding(str, width, char) { | |
const msgs = str.split(' ') | |
msgs.forEach((msg) => { | |
const wordLength = msg.length | |
let totalPadding = width - wordLength | |
const padding = { | |
start: totalPadding / 2, |
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 foo(delay) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(Math.random()) | |
}, delay) | |
}) | |
} | |
async function run(delaySeconds) { | |
const a = foo(delaySeconds * 1000) |
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
// Combine these to write sentences! | |
(+!+[]) // 1 - use it to pick an index from any of the strings in this list | |
(-(+!+[])+(+!+[])) // 0 | |
([![]]+[][[]]) // "falseundefined", you can then pick a character via index by adding 1s | |
(![]+[]) // "false" | |
(!+[]+[]) // "true" | |
// JavaScript return types we are exploiting: | |
// false, true, undefined, 0, 1 |
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
{"status":200,"message":"OK","body":{"titleInternal":"Visit Planner Page","pageProfiles":{"titleInternal":"Visit Planner Page (default)","title":{"titleInternal":"Visit Planner Page: Title","text":"Plan your day at the Museum","contextProfile":null,"link":[],"contentType":"contextualShortText"},"description":{"titleInternal":"Page profile: Visit Planner Page: Description","text":"We've put together some key information to help you customise your itinerary for your visit to the Museum.","title":[],"contextProfile":null,"link":[],"contentType":"contextualLongText"},"heroWidget":[],"heroFooterBlock":[],"leadImage":{"titleInternal":"Contextual image: Page divider: Clock detail","image":{"titleInternal":"Image: Page divider: Clock detail","notesInternal":null,"caption":null,"image":{"title":"visual banner objects 4 1920x1000","file":{"fileName":"visual_banner_objects_4_1920x1000.jpg","contentType":"image/jpeg","details":{"size":1655645,"image":{"width":1920,"height":1000}},"url":"//images.contentful.com/ux95v64xm8 |
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
# Welcome message | |
open_green_escape="\033[36m" | |
open_yellow_escape="\033[31m" | |
close_escape="\033[0m" | |
# Some of my fave peep show quotes. | |
funny_quotes=( | |
'What if I lose it? Im not gonna do a poo am I, Jez?' | |
'For the worst thing that could possibly happen, this is actually going extremely well.' | |
'Is this a terrible idea? It cant be. Its in a film. They wouldnt put a terrible idea in a film, theyd get sued.' |
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
INSERT INTO `videos` (`url`, `id`, `title`, `description`) VALUES | |
('7rl6gtTrj04', 171, 'Snoop Dogg X Wiz Khalifa - That Good (HD/Download)', 'http://smokethechronic.tumblr.com/\r\n\r\nSnoop Dogg X Wiz Khalifa - That Good (HD/Download)\r\nSnoop Dogg X Wiz Khalifa - That Good (HD/Download)\r\nSnoop Dogg X Wiz Khalifa - That Good (HD/Download)\r\n\r\nDownload @ http://hulkshare.com/a2mkyr07mqx7'), | |
('fBFECD00fGw', 107, 'Emalkay - A.G.S. (Angie Got Stoned)', 'Subscribe if you like the videos.\r\nAll Copyright©(P) Goes To The Rightfull Owners of the Tracks. \r\nPlease Check Out My Website http://www.UpBeat-Music.co.uk\r\n\r\nThanks! :)\r\n\r\nBuy this track here\r\nhttp://www.chemical-records.co.uk/sc/servlet/Info?Track=DP034'), | |
('ldQUDv4bxxI', 108, 'Distance - Falling (Original Radio Edit)', 'big tune from Distance.'), | |
('_4vKWFCWw04', 68, 'Xxplosive - Dr. Dre', 'R.I.P. Nate Dogg\r\n\r\nClassic track by Dr. Dre from his album 2001\r\n\r\nSong: Xxplosive\r\nArtist: Dr. Dre ft. Hittman, Kurupt, Nate Dogg, & Six-Two\ |