Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jhsu's full-sized avatar
💀
compliant with future standards

Joe Hsu jhsu

💀
compliant with future standards
  • MineHub
  • New York, NY
  • X @jhsu
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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);
@jhsu
jhsu / trimet.py
Last active February 7, 2019 22:43
import os
import requests
import time
import datetime
import sys
import signal
from papirus import PapirusComposite
screen = PapirusComposite(False)
function* fib(a, b) {
let c = 0
yield a
yield b
while (true) {
c = a + b
a = b
b = c
yield c
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,
});
var something = require('hello');
var letter = 'A';
function FooBar(words) {
var b = words || 'hello there';
return something(b + "WOOOO");
}
FooBar(letter);
@jhsu
jhsu / reactjs test.carbide.md
Last active August 25, 2016 08:31
reactjs test
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);
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>