Skip to content

Instantly share code, notes, and snippets.

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):
@joetastic
joetastic / gist:487328c98e30d74cc2bb
Last active August 29, 2015 14:02
An app to register for a foosball tournament ahead of time
  • sign up with name and email
  • show currently available tournament(s) and registered TD
  • accept payment via venmo (required to make somebody commit)
  • chat (to say you're late etc.)
  • list players who have showed up and if they've paid
  • show if players are planning on coming but having paid
  • integrate with swarm(foursquare) (plans + checkins)