Skip to content

Instantly share code, notes, and snippets.

Avatar

Jordan Brennan jfbrennan

  • OctoML
  • Puyallup, WA
View GitHub Profile
@jfbrennan
jfbrennan / riot-template.html
Last active Mar 29, 2020
Riot component with all the basics
View riot-template.html
<my-todos>
<p>Todo count: {state.todos.length}</p>
<input ref="newTodo" type="text">
<button onclick="{add}">Add</button>
<ul if="{state.todos.length}">
<li each="{(todo, i) in state.todos}" key="{i}">{todo} <button onclick="{e => remove(i)}">Remove</button></li>
</ul>
<script>
export default {
@jfbrennan
jfbrennan / vue-sfc-template.html
Last active Mar 29, 2020
Vue Single File Component with all the basics
View vue-sfc-template.html
<template>
<p>Todo count: {{todos.length}}</p>
<input ref="newTodo" type="text">
<button v-on:click="add">Add</button>
<ul v-if="todos.length">
<li v-for="(todo, i) of todos" :key="i">{{todo}} <button v-on:click="remove(i)">Remove</button></li>
</ul>
</template>
<script>
@jfbrennan
jfbrennan / num-to-digits.js
Last active Mar 28, 2020
JavaScript convert number to array of digits
View num-to-digits.js
const num = 123
let digits
// Option A
digits = num.toString().split('').map(Number)
console.log(digits) // [1, 2, 3]
// Option B
digits = Array.from(String(num), Number)
console.log(digits) // [1, 2, 3]
@jfbrennan
jfbrennan / find-pairs.js
Created Mar 17, 2020
Student-Course Pairs
View find-pairs.js
const studentCoursePairs1 = [
["58", "Linear Algebra"],
["94", "Art History"],
["94", "Operating Systems"],
["17", "Software Design"],
["58", "Mechanics"],
["58", "Economics"],
["17", "Linear Algebra"],
["17", "Political Science"],
["94", "Economics"],
@jfbrennan
jfbrennan / ReactAlert.js
Last active Jan 25, 2018
Alert UI component rebuilt to compare Riot vs Slim vs Polymer vs Vue vs React and more
View ReactAlert.js
import React, {Component} from 'react'
import PropTypes from 'prop-types'
class ReactAlert extends Component {
static defaultProps = {
icon: null,
msg: '',
type: 'info',
autodismiss: 0,
onRemoveAlert: () => {}
You can’t perform that action at this time.