Skip to content

Instantly share code, notes, and snippets.

@MrHus
MrHus / Tetris.tsx
Last active October 4, 2023 07:04
A tetris implemented in TypeScript and React
'use client';
import React from 'react';
import { useRef, useEffect } from 'react';
// The dimensions of the tetris game.
const WIDTH = 300;
const HEIGHT = 500;
// The height of the topbar, in which the score and title of the
import { useEffect, useRef } from 'react';
// CONFIG
const WIDTH = 660;
const HEIGHT = 440;
const COLUMN_WIDTH = 20;
const COLUMNS = WIDTH / COLUMN_WIDTH;
@MrHus
MrHus / hunter.js
Created July 21, 2017 09:53
Find all material-icons on https://material.io/icons/
/*
Wanted a list to get all the names for each material design
icon. Could not find a list online, other than the page at:
https://material.io/icons/
So I wrote a script to get all the icons from that page. Unfortunately
it is made in polymer which uses the shadowdom extensively. So
getting all the icons means digging through the entire dom and shadow
dom.
@MrHus
MrHus / PersonDetail.test.js
Created June 8, 2017 08:25
The PersonDetail component test with useful assertions
// @flow
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import PersonDetail from './PersonDetail';
describe('Component: PersonDetail', () => {
test('ui', () => {
@MrHus
MrHus / DeleteButton.js
Last active June 8, 2017 08:02
The DeleteButton Component
// @flow
import React from 'react';
type Props = {
onClick: () => void
};
export default function DeleteButton(props: Props) {
return (
@MrHus
MrHus / PersonDetail.test.js
Created June 8, 2017 08:01
The PersonDetail Component
// @flow
import React, { Component } from 'react';
import DeleteButton from './DeleteButton';
type Person = {
id: number,
name: string,
age: number
@MrHus
MrHus / PersonDetail.test.js
Last active June 8, 2017 08:21
The test file for the PersonDetail component
// @flow
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import PersonDetail from './PersonDetail';
describe('Component: PersonDetail', () => {
test('ui', () => {
@MrHus
MrHus / output.html
Last active June 8, 2017 07:59
Terminal output of the console.log line on line 14
<div class="panel">
<h1>Maarten</h1>
<h2>28</h2>
<DeleteButton onClick={[Function]} />
</div>
@MrHus
MrHus / Pager.js
Created February 14, 2017 11:29
Incomplete coverage
// @flow
import React, { Component } from 'react';
type Props = {
hasNext: bool,
hasPrevious: bool,
nextClicked: () => void,
previousClicked: () => void
};
@MrHus
MrHus / gist:5370481
Last active December 16, 2015 03:29
Cheshire encoder for org.postgresql.jdbc4.Jdbc4Array
(ns foo.bar
(:require [cheshire.core :refer :all]
[cheshire.generate :refer [add-encoder]]))
(add-encoder org.postgresql.jdbc4.Jdbc4Array
(fn [array jsonGenerator]
(let [sequence (seq (.getArray array))]
(.writeStartArray jsonGenerator)
(doseq [i sequence]
(.writeString jsonGenerator i))