Skip to content

Instantly share code, notes, and snippets.

Adam Bard adambard

Block or report user

Report or block adambard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adambard
adambard / HLLField.py
Created Jul 25, 2018
A Django HLLField (HyperLogLog)
View HLLField.py
# Presented without warranty, but seems to work ok
from django.db import models
# From https://github.com/ascv/HyperLogLog
from HLL import HyperLogLog
def init_hll(m, seed, bytes=None):
hll = HyperLogLog(m, seed)
@adambard
adambard / grpc.ts
Created Sep 9, 2017
React GRPC HOC
View grpc.ts
import * as jspb from 'google-protobuf'
import { Code, grpc } from 'grpc-web-client'
import React from 'react'
export interface RPCResponseData<TResult, TOwnProps> {
ownProps: TOwnProps
loading: boolean
result: TResult | null
status: Code | null
statusMessage: string
@adambard
adambard / async.fs
Created Aug 10, 2017
map, bind, and unit for F# Async
View async.fs
type Microsoft.FSharp.Control.Async with
static member unit (t:'T) : Async<'T> = async { return t }
static member bind (fn:'T -> Async<'U>) (t: Async<'T>) : Async<'U> =
async {
let! input = t
return! fn(input)
}
static member map (fn:'T -> 'U) (t:Async<'T>) : Async<'U> =
async {
let! input = t
@adambard
adambard / stuff.py
Created Nov 6, 2016
Stats on new Hearthstone discover cards
View stuff.py
import json
import random
import numpy
from collections import namedtuple
## LOAD CARDS
with open("cards.collectible.json") as f:
cards = json.load(f)
cards = [c for c in cards if 'cost' in c and 'text' in c]
View Blink.tsx
View gist:2e2af4d31705efe5e41bd58283276a7d
calculatesum=function(html){
//! This function doesn't seem to do anything, since it's only ever called with an element's innerHTML.
var tmp = document.createElement("DIV")
tmp.innerHTML = html
return tmp.textContent||tmp.innerText
}
getColumnCount=function()
{
@adambard
adambard / table.html
Created Apr 27, 2016
Make and style an HTML table with column groups
View table.html
<html>
<head>
<style>
table {
width: 900px;
margin: 0 auto;
border-collapse: collapse;
border: 1px solid;
}
th {
@adambard
adambard / Tapstream.md
Last active May 5, 2016
Instructions for Tapstream-Segment js integration
View Tapstream.md

Getting Started

Tapstream integrates with Segment to simplify and consolidate tracking of user events.

Tapstream attempts to connect in-browser actions with in-app actions, to provide analytics that cross the browser-app border. So, for browser integrations, both track and page calls will be saved as Tapstream "hits" -- browser-side interactions. In the mobile SDK, track will instead send a Tapstream "event", specifying a mobile app interaction.

Browser Integration Instructions

View tapstream_logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View script.js
url = require('url')
http = require('http')
https = require('https')
r = require('readability-node')
jsdom = require('jsdom').jsdom
function handleRequest(request, response){
var uri = url.parse(request.url, true).query.url;
uri = url.parse(uri || "https://medium.com/@mbostock/what-makes-software-good-943557f8a488")
https.get(uri, function(res){
You can’t perform that action at this time.