This Gist was automatically created by Carbide, a free online programming environment.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 { useEffect, useRef } from "react"; | |
export function useKeyPress(key: string, handler: (evt: Event) => void) { | |
const eventListenerRef = useRef<(evt: KeyboardEvent) => void>(); | |
useEffect(() => { | |
console.log("redefine movement"); | |
eventListenerRef.current = (event: KeyboardEvent) => { | |
if (event.key === key) { | |
handler?.(event); |
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 os | |
import requests | |
import time | |
import datetime | |
import sys | |
import signal | |
from papirus import PapirusComposite | |
screen = PapirusComposite(False) |
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* fib(a, b) { | |
let c = 0 | |
yield a | |
yield b | |
while (true) { | |
c = a + b | |
a = b | |
b = c | |
yield c |
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 Camera from './Camera'; | |
import Shake from 'shake.js'; | |
class Player extends Component { | |
componentDidMount() { | |
this.shaker = new Shake({ | |
threshold: 5, | |
timeout: 250, | |
}); |
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
var something = require('hello'); | |
var letter = 'A'; | |
function FooBar(words) { | |
var b = words || 'hello there'; | |
return something(b + "WOOOO"); | |
} | |
FooBar(letter); |
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 toRad(deg) { | |
return deg * (Math.PI / 180); | |
} | |
function toDeg(rad) { | |
return rad / (Math.PI / 180); | |
} | |
const EARTH_R = 6378.1; | |
function getNewCoords(initLoc, distance, bearing) { | |
const bearingR = toRad(bearing); |
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
const ExampleApp = React.createClass({ | |
render: function() { | |
return ( | |
<View style={styles.container}> | |
<View style={styles.borderH}></View> | |
<View style={styles.contentH}> | |
<View style={styles.contentV}> | |
<View style={styles.contentH}> | |
<View style={styles.borderV}> | |
</View> |
NewerOlder