Skip to content

Instantly share code, notes, and snippets.

const describe = (desc, fn) => {
console.log(desc)
fn()
}
const it = (msg, fn) => describe(' ' + msg, fn)
const matchers = (exp) => ({
toBe: (asssertion) => {
if (exp === assertion) {
const {
describe,
it,
expect,
matchers
} = require('./index')
let executes = 0
const noop = () => { executes += 1 }
describe('expect', () => {
it('returns an object', () => {
const actual = expect(true)
expect(typeof actual).toBe('object')
expect(typeof actual.toBe).toBe('function')
})
})
describe('matchers', () => {
describe('toBe', () => {
it('works', () => {
const actual = matchers('1').toBe('1')
expect(actual).toBe(true)
})
})
})
const {
describe,
it,
expect,
matchers
} = require('./index')
let executes = 0
const noop = () => { executes += 1 }
import matplotlib.pyplot as plt
import numpy as np
# original data set
X = [1, 2, 3]
y = [1, 2.5, 3.5]
# slope of best_fit_1 is 0.5
# slope of best_fit_2 is 1.0
# slope of best_fit_3 is 1.5
import numpy as np
X = np.array([[1], [2], [3]])
y = np.array([[1], [2.5], [3.5]])
get_theta = lambda theta: np.array([[0, theta]])
thetas = list(map(get_theta, [0.5, 1.0, 1.5]))
X = np.hstack([np.ones([3, 1]), X])
// store.js
const state = {
first: "",
last: ""
}
export const getters = {
message: (state) => {
return state.first + ' ' + state.last
}
<template>
<div>
<div>{{ msg }}</div>
<div>{{ post.title }}</div>
</div>
</template>
// ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.rawgit.com/vuejs/vue/dev/dist/vue.min.js"></script>
<script src="https://cdn.rawgit.com/vuejs/vue/dev/packages/vue-template-compiler/browser.js"></script>
<script src="https://cdn.rawgit.com/vuejs/vue-test-utils/dev/packages/test-utils/dist/vue-test-utils.iife.js"></script>
<script src="https://cdn.rawgit.com/Automattic/expect.js/0.3.1/index.js"></script>
<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" />