This file contains hidden or 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 Component() { | |
const [items, setItems] = useState([]) | |
async function fetchItems(abortSignal: AbortSignal) { | |
try { | |
const res = await fetch(`/api/items/`, { signal: abortSignal }) | |
const resp = await res.json() | |
if (res.ok && resp.ok) { | |
setItems(resp.items) | |
} else { |
This file contains hidden or 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 hdup() { | |
if [ "$1" != "" ] | |
then | |
heroku apps:create $1 --region eu -s container | |
echo "build:\n docker:\n web: Dockerfile" > heroku.yml | |
touch Dockerfile | |
else | |
echo "Please provide an app name." | |
fi | |
} |
This file contains hidden or 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 { wrapText } from './wrap-text' | |
// Drawing and highlighting words (twitter style) | |
wrapText({ | |
ctx, | |
text: text, | |
x: 0, | |
y: 0, | |
maxWidth: 500, | |
lineHeight: fontSize * 1.2, |
This file contains hidden or 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
// @flow | |
import cache from 'memory-cache' | |
import fetch from 'isomorphic-fetch' | |
const TTL_MILISECONDS: number = 10 * 60 * 1000 // ten minutes | |
export default async function<T>(url: string, options?: Object): Promise<T> { | |
const cachedResponse = cache.get(url) | |
if (cachedResponse) return cachedResponse |
This file contains hidden or 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
// @flow | |
import * as React from 'react' | |
import Clipboard, { type ClipboardType } from 'clipboard' | |
type Props = { | |
text: string, | |
onSuccess?: () => any, | |
children: React.Node, | |
} |
This file contains hidden or 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 selectText(element) { | |
let range | |
let selection | |
if (document.body.createTextRange) { | |
//ms | |
range = document.body.createTextRange() | |
range.moveToElementText(element) | |
range.select() | |
} else if (window.getSelection) { | |
//all others |
This file contains hidden or 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
// random hex | |
'#'+Math.random().toString(16).slice(-6) | |
'#'+(~~(Math.random()*0xffffff)).toString(16) | |
'#'+parseInt(Math.random()*0xffffff).toString(16) | |
// random rgb | |
r=_=>(Math.random()*255|0),`rgb(${[r(),r(),r()]})` | |
// random rgba | |
r=_=>(Math.random()*255|0),`rgba(${[r(),r(),r()]},1)` |
This file contains hidden or 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' | |
export default class WithSwipe extends React.Component { | |
xDown = null | |
yDown = null | |
handleTouchStart = evt => { | |
this.xDown = evt.touches[0].clientX | |
this.yDown = evt.touches[0].clientY | |
} |
This file contains hidden or 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
{ | |
"Working Directory" : "\/Users\/rista\/Projects", | |
"Prompt Before Closing 2" : 0, | |
"Selected Text Color" : { | |
"Green Component" : 0, | |
"Red Component" : 0, | |
"Blue Component" : 0 | |
}, | |
"Rows" : 30, | |
"Ansi 11 Color" : { |
This file contains hidden or 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 html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>HTML5 Canvas</title> | |
<style> | |
* { | |
box-sizing: border-box; | |
} | |
html, body { |
NewerOlder