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
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)
@krawaller
krawaller / directives.md
Last active Jan 27, 2016
Grokking angular by claims
View directives.md
  • ng-submit * only makes sense on a <form> tag * is just an event handler much like ng-click
  • ng-options * only makes sense on a <select> tag * enables us to have objects as selected values instead of just strings * saves us from having to type out <options ng-repeat="..." ... /> * provides additional shortcut for <optgroup> through :groupBy
  • ng-click
  • should always be a method call, don't do assignments as that relies on brittle scoping and is hard to test
    
You can’t perform that action at this time.