Skip to content

Instantly share code, notes, and snippets.

Writing Style Guide

Core principle

Write for an intelligent reader who may not already know the vocabulary of the subject.

Do not simplify ideas merely because they are complex. Simplify the language required to understand them.

Assume the reader is capable of understanding statistics, systems, technology, science, organizational behavior, experimentation, or other specialized subjects when they are explained clearly.

lg = log --pretty=format:'%Cred%h%Creset %C(bold blue)<%an>%Creset%C(yellow)%d%Creset %Cgreen(%cr)%Creset %s'
import * as React from "react";
type TypeA = 'TypeA';
type TypeB = 'TypeB';
interface WithA {
propertyA: TypeA
}
interface WithAB {
import tornado.web
import tornado.options
import logging
class IndexHandler(tornado.web.RequestHandler):
def get(self):
self.finish('oh yeah, i got it')
def main():
tornado.options.parse_command_line()
@joetastic
joetastic / _.js
Last active November 22, 2015 20:57
var fog, board;
var createFog = function() {
var canvas = document.createElement('canvas');
canvas.width = board.width;
canvas.height = board.height;
var context = canvas.getContext('2d');
context.fill('black', 0, 0, board.width, board.height);
fog = canvas;
};
import cv2, numpy as np
FIELD_CORNERS = (
(153, 36), (456, 37),
(74, 461), (518, 460)
)
def get_ball_template():
template = np.zeros((22, 22), dtype=np.uint8)
cv2.circle(template, (11, 11), 11, 255, -1)
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from tornado.options import options
def get_engine(memo=[]):
if len(memo) == 0:
memo.append(
RSpec.configure do |config|
config.before :each do
embedly_api_response = [double('embedly', original_url: 'http://quirky.com',
images: [], media: double('media', html: nil),
description: nil, app_links: [], title: nil,
provider_name: nil)]
allow_any_instance_of(Embedly::API).to receive(:extract)
.and_return(embedly_api_response)
end
thumbFromVideo: function(embed, quality) {
console.log('thumb for video', embed);
embed = embed.trim(); // who knows why
var hash, u;
if (embed.search(/https?:\/\/abc\.go\.com/) >= 0) {
hash = embed.match(/https?:\/\/abc\.go\.com\/embed\/([^\/\?"]*)/).pop();
return 'http://static.east.abc.go.com/service/image/ratio/id/' + hash + '/dim/160.1x1.jpg';
} else if (embed.indexOf('<') >= 0) {
hash = $(embed).attr('src').match(/embed\/(.*)$/)[1];
} else if (embed.search(/^https?:\/\/(www\.)?youtube.com/) >= 0) {
@joetastic
joetastic / transform.py
Created July 16, 2014 16:44
A python function for two way dictionary transformations
from collections import defaultdict
example_map= (
('n.given_name', 'first'),
('n.family_name', 'last'),
('tel.value', 'tel'),
('tel.type', 'teltype')
)
def transform(source, map_, reverse=False):