Skip to content

Instantly share code, notes, and snippets.

View traviskaufman's full-sized avatar

Travis Kaufman traviskaufman

View GitHub Profile
@traviskaufman
traviskaufman / mdc-web-closure-compatibility.md
Created February 22, 2017 16:30
MDC-Web Closure Compatibility

material-components/material-components-web#134

Closure Compiler Support

Google Closure Compiler support is required in order to support the Google projects and properties which are built around this toolchain. Concretely, MDC-Web must be able to compile with ADVANCED_OPTIMIZATIONS enabled, and produce no errors or warnings. There are implications for internal support as well, but that is outside the scope of this issue.

Goals

  • Full compilation of MDC-Web using ADVANCED_OPTIMIZATIONS
  • Test infrastructure to verify both compilation, as well as runtime correctness, e.g. our closurized code behaves correctly
@traviskaufman
traviskaufman / mdc-web-tape2mocha.js
Created February 16, 2017 21:09
one-off script to transform MDC-Web's tests from tape to mocha (https://github.com/material-components/material-components-web/issues/143)
/**
* @fileoverview one-off script to transform MDC-Web's tests from tape to mocha.
* See https://github.com/material-components/material-components-web/issues/143
*/
const fs = require('fs');
const path = require('path');
const babylon = require('babylon');
const glob = require('glob');
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# ipython-utils/setup.py
setup(
name='ipython-utils',
packages=find_packages(),
install_requires=[
'ipython >= 4',
'notebook >= 4.3.1',
'jupyter',
'numpy',
'pandas',
%%bq --name hn_daily_comment_counts
SELECT
TIMESTAMP_TRUNC(time_ts, DAY) as day,
COUNT(0) as comment_count
FROM
`bigquery-public-data.hacker_news.comments`
GROUP BY
day
ORDER BY
day ASC;
# ipython-utils/researchenv/__init__.py
# imports...
from researchenv.magics import ResearchEnvMagics
from google.cloud import bigquery
def load_ipython_extension(ipython: InteractiveShell):
# previous logic...
bq = bigquery.Client(project='example-project-id')
ipython.register_magics(ResearchEnvMagics(shell=ipython, bq=bq))
# ipython-utils/researchenv/__init__.py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from IPython.core.interactiveshell import InteractiveShell
def load_ipython_extension(ipython: InteractiveShell):
print('%matplotlib inline')
# ipython-utils/researchenv/magics.py
from IPython.core.magic import Magics, magics_class, cell_magic, needs_local_scope
from IPython.core.magic_arguments import magic_arguments, argument, parse_argstring
from IPython.core.interactiveshell import InteractiveShell
from IPython.core.display import display
from google.cloud import bigquery
@magics_class
class ResearchEnvMagics(Magics):
@traviskaufman
traviskaufman / 01-demystifying-rxjs-observable.ts
Last active October 18, 2019 17:56
Demystifying RxJS Part I: Observable Implementation
interface Observer<T> {
next(value: T): void;
error(err: any): void;
complete(): void;
}
interface Subscription {
unsubscribe(): void;
}
@traviskaufman
traviskaufman / 02-demystifying-rxjs-observable-test.ts
Created October 18, 2019 18:00
Demystifying RxJS, Part I: Basic Observable Test
const observable = new Observable(subscriber => {
subscriber.next(1);
subscriber.next(2);
subscriber.next(3);
setTimeout(() => {
subscriber.next(4);
subscriber.complete();
}, 1000);
});