Skip to content

Instantly share code, notes, and snippets.

@stevenpollack
stevenpollack / init.d_jupyter-notebook
Created March 18, 2016 15:29
jupyter notebook init.d for vagrant
#! /bin/sh
### BEGIN INIT INFO
# Provides: jupyter-notebook
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start jupyter-notebook
# Description: This file starts a jupyter-notebook session using config
# parameters specified in ~/.jupyter/jupyter_notebook_config.py
@stevenpollack
stevenpollack / async_crawl.py
Last active April 25, 2016 14:13
Perform an async crawl of google.com/movies when we're not sure how many pages we need to crawl...
def crawl(self, current_page):
# modifies various attributes of self depending on the
# html in current_page and returns nothing.
@coroutine
def coro(current_page):
# either return a future of the body of the "next" page or None
next_page_url = next_page_link(current_page)
if next_page_url is None:
yield None
@stevenpollack
stevenpollack / false.js
Last active May 25, 2016 16:00
Javascript "falsey" values
var falseyValues = [
false,
0,
undefined,
NaN,
"",
null
];
falseyValues.map(function (x) {return x ? true : false;}); // [false, false, false, false, false, false]
@stevenpollack
stevenpollack / demo.css
Last active June 2, 2016 12:29
CSS selectors
/* basic selection: all <p> tags */
p {
color: red;
}
/* descendent selector:
all <li> tags that are children of <ul> tags
*/
ul li {
font-size: 24 px;
@stevenpollack
stevenpollack / _color_theory_101.md
Last active June 3, 2016 15:08
fundamentals of design

Two types of color:

  • subtractive: "color you can touch" (e.g., skin of an apple)
    • controlled by CMYK colorspace
  • additive: "color you can't touch" (e.g., light from a computer screen)
    • controlled by RBG colorspace

Humans process color in HSL (Hue, Saturation, Lightness):

  • best visualized as a colorwheel:
    • hue is measured in degrees (red: 0º, green: 120º, blue: 240º)
  • saturation goes from 0 to 100% where 0% is grey and 100% is as vivid as possible
@stevenpollack
stevenpollack / demo.scss
Last active June 8, 2016 14:29
Sass basics
/*
- elem1 { elem2 { ... } }
has the effect of compiling to elem1 elem2 { ... }
- .class1 { &.class2 { ... } }
compiles to .class1.class2 { ... }
- .class1 { .class2 & { ... } }
compiles to .class2 .class1 { ... }
*/
nav {
h1 {
// React components must extend the React.Component Class
// and therefore expose a render method, which returns
// JSX (JavaScript XML).
// JSX looks exactly like unquoted HTML, except that
// - the HTML 'class' attribute is referenced via 'className'
// - we can mix in javascript via code blocks enclosed in {}
// - we can send arguments ('props' in React) to components:
// + props are accessed via the `this.props` object
// - we can access state with (`this.state`)
class Comment extends React.Component {
import React, { Component } from 'react'
import './App.css'
import ValidationComponent from './ValidationComponent'
import CharComponent from './CharComponent'
class App extends Component {
state = {
userText: '',
textLength: 0,
textArr: []