Skip to content

Instantly share code, notes, and snippets.

David Waller krawaller

Block or report user

Report or block krawaller

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@krawaller
krawaller / LegoSetImage.js
Last active Oct 14, 2019
Redux useSelector and useDispatch hook test example
View LegoSetImage.js
import React, { FunctionComponent } from "react";
import { useSelector, useDispatch } from "react-redux";
import { selectCurrentSet, zoomImage } from "../dataLayer";
export const LegoSetImage: FunctionComponent = () => {
const set = useSelector(selectCurrentSet);
const dispatch = useDispatch()
const zoomHandler = () => dispatch(zoomImage(set.set_img_url))
return (
<div className="legoSetImageContainer">
View Guesses_index.js
import React from "react";
export const Guesses = props => {
return (
<React.Fragment>
<h4>Guesses:</h4>
<ul>
{props.guesses.map((guess, n) => (
<li key={n}>{guess}</li>
))}
View todo.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.done {
background-color: #DDD;
@krawaller
krawaller / object.js
Created Nov 1, 2017
object lookup examples
View object.js
var me = {
name: "David Waller",
nickName: "Davve",
prop: "kopp"
};
var formalSituation = true;
var prop;
@krawaller
krawaller / components.ts
Created Jul 25, 2017
Angular components as table rows
View components.ts
import { Component, Input } from '@angular/core';
@Component({
selector: 'app',
template: `
<table>
<tr magicrow msg="hello"></tr>
<tr magicrow msg="world"></tr>
</table>
`,
View typedcontainers.md

To create a container, I only need to add my AppState typings to the mapStateToProps parameter:

const mapStateToProps = (state: State) => ({
  messages: state.messaging.messages
});

const mapDispatchToProps = (dispatch) => ({
  dismissUIMessage: (num) => dispatch(actions.dismissUIMessage(num))
});
@krawaller
krawaller / firebase.md
Created May 9, 2017
Enforcing Firebase relation validity
View firebase.md

Say we have a database of users and roles, where each user belongs to a role. Using the denormalized Firebase approach I might store that like this:

{
  "users": {
    "abc123": {
      "name": "Joe",
      "role": "kkk333"
    },
    // lots more users
@krawaller
krawaller / ng.html
Created May 10, 2016
fun fun angular stuff :)
View ng.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Exercise 1</title>
<style>
.done {
text-decoration: line-through;
}
@krawaller
krawaller / exercise1.html
Last active May 10, 2016
angular cheating
View exercise1.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Exercise 1</title>
<script src="../jquery.js"></script>
<script src="../angular.js"></script>
<style>
.selected {
text-decoration: line-through;
View myapp.js
angular.module('myApp',[])
.factory('tags',function(){
var tags = ['urgent','blocked','boring','hard'],
callbacks = [];
return {
addTag: function(t){
tags.push(t);
callbacks.forEach(function(cb){
cb(tags)
You can’t perform that action at this time.