Skip to content

Instantly share code, notes, and snippets.

View togakangaroo's full-sized avatar

George Mauer togakangaroo

View GitHub Profile
import { expect } from 'chai'
describe(`Given a stopwatch`, () => {
let sw
beforeEach(() => sw = createStopWatch())
it(`shows nothing on main display`, () => expect(sw.displays.main).to.equal(null))
it(`shows no laps`, () => expect(sw.displays.laps).to.deep.equal([]))
})

Greatest Common Divisor of Strings

From the Operation Code Slack

Problem statement:

For strings S and T, we say “T divides S” if and only if S = T + ... + T  (T concatenated with itself 1 or more times)
Return the largest string X such that X divides str1 and X divides str2.
```
Input: str1 = "ABCABC", str2 = "ABC"
@togakangaroo
togakangaroo / daily programmer gcd of strings.html
Created October 14, 2019 17:32
an example of doing an op-code #daily-programmer challenge with literate coding
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2019-10-14 Mon 12:29 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>&lrm;</title>
<meta name="generator" content="Org mode" />
<style id="jsbin-css">
ul {
list-style-type: none;
padding: 0;
display: inline-flex;
font-size: 50px;
outline: 1px solid red;
width: 5em;
overflow: hidden;
}
<style id="jsbin-css">
section {
overflow: hidden;
background-color: teal;
height: calc(5 * 2.6ex);
line-height: 2.6ex;
}
section p {
float: right;
margin: 0;
const CompactOrder = (props) => (
<section class="order" onclick={() => props.select(props.item) }>
<p>{props.item.name}</p>
</section>
)
class OrderList {
_constructor () {
window.console = skewer
var createCounter = (startVal = 0) => {
let state = startVal
return {
next: () => {
if(state < (10 + startVal))
return {value: state+=1}
return {done: true}
}
var createCounter = (startVal = 0) => {
let state = startVal
return {
next: () => {
if(state < (10 + startVal))
return {value: state+=1}
return {done: true}
}
}
}
var createCounter = (startVal = 0) => {
let state = startVal
return {
next: () => {
if(state < (10 + startVal))
return {value: state+=1}
return {done: true}
}
}
}
#!/usr/bin/python
from subprocess import check_output
# Originally from http://stackoverflow.com/questions/23122183/can-you-close-a-mercurial-branch-without-updating-to-it-first
def close_branch( branch, message ):
if not message:
message = 'Closing branch "{}"'.format( branch )
print( 'Closing branch "{}"'.format( branch ) )