Skip to content

Instantly share code, notes, and snippets.

Jamie Kyle jamiebuilds

Block or report user

Report or block jamiebuilds

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 print-with-generator.js
let INDENT = { op: "indent" }
let OUTDENT = { op: "outdent" }
let NEWLINE = { op: "newline" }
let SPACE = { op: "space" }
function* printNode(node) {
if (node.type === "Program") {
for (let item of node.body) {
yield* printNode(item)
yield NEWLINE
View tree.js
class Tree {
constructor() {
this.children = []
}
add(value, parentValue) {
let newNode = { value, children: [] }
if (parentValue === null) {
this.children.push(newNode)
View the-challenge.md

The Challenge

Compare two (or more) tools that are trying to solve a similar set of problems, without discussing any of the following:

  • Community
  • Programming Language
  • Documentation/Examples/Demos/etc
  • Stars/Forks/Downloads/Issues/PRs/Stack Overflow Answers/etc
  • Age/Maturity of tool
View jquery.plugin-template.js
// if (!window.L) { window.L = function () { console.log(arguments);} } // optional EZ quick logging for debugging
/**
* A modified (improved?) version of the jQuery plugin design pattern
* See http://docs.jquery.com/Plugins/Authoring (near the bottom) for details.
*
* ADVANTAGES OF EITHER FRAMEWORK:
* - Encapsulates additional plugin action methods without polluting the jQuery.fn namespace
* - Ensures ability to use '$' even in compat modes
*
View import-html-with-exports.md

Question:

In a generic sense (aka, not within any particular tool or framework, not the behavior of the tool or framework that you work in)...

If you had an HTML file that looked like this:

<!doctype html>
<script type="module">
  export default "jsvalue"
@jamiebuilds
jamiebuilds / 1-state.tsx
Last active Mar 6, 2019
Unstated 3.0 proposal
View 1-state.tsx
import React from "react"
import { render } from "react-dom"
import { createContextState, useContextState, Provider } from "unstated"
‪let Count = createContextState(0)
‪function useCounter() {
let [count, setCount] = useContextState(Count)
let increment = () => setCount(count + 1)
let decrement = () => setCount(count - 1)
View a-redux-story.md

A Redux Story

Developer: "Doo Doo Doo... Working on the new Redux rewrite. Gotta write some fetch actions..."

FETCH_USERS -> function fetchUsersAction() {...}
FETCH_PAGES -> function fetchPagesAction() {...}
FETCH_FRIENDS -> function fetchFriendsAction() {...}
FETCH_GROUPS -> function fetchGroupsAction() {...}
FETCH_EVENTS -> function fetchEventsAction() {...}
View a-single-piece-of-code-on-github-that-does-that.js
getMap()
.set(“a”, “A”)
.set(“b”, ”B”)
.set (“etc”, “ETC”);
View server.js
import express from 'express';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import App from './components/App';
import {flushServerSideRequires} from 'react-loadable';
let app = express();
let webpackStats = require('./output-webpack-stats.json');
View map-with-create-value.js
class AwesomeMap extends Map {
get(key, createValue) {
if (!this.has(key) && createValue) {
let value = createValue();
this.set(key, value);
return value;
} else {
return this.get(key);
}
}
You can’t perform that action at this time.