Skip to content

Instantly share code, notes, and snippets.

View bnorberg's full-sized avatar

Brian Norberg bnorberg

View GitHub Profile
import cognitive_face as CF
import requests
from io import BytesIO
from PIL import Image, ImageDraw
KEY = 'ADD YOUR FACE API KEY HERE' # Replace with a valid subscription key (keeping the quotes in place).
CF.Key.set(KEY)
BASE_URL = 'https://westcentralus.api.cognitive.microsoft.com/face/v1.0/' # Replace with your regional Base URL
<html>
<head>
<style>
#mapid { height: 620px; }
</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"
integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<div id="api-data"></div>
<script type="text/javascript">
<!-- copy lines 1-11 of the JavaScript Jquery AJAX code given by Postman -->
<html>
<head>
<style>
#mapid { height: 680px; }
</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"
integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
<html>
<head>
<!-- include references to CSS and JavaScript files -->
<style>
<!-- put css code here -->
</style>
</head>
<body>
<!-- create your map div here -->
<script type="text/javascript">
@bnorberg
bnorberg / Roots API Workshop Bike Crash Google Map Example
Created February 26, 2018 15:09
Google map with bike crash data included. Add your Google Maps API key in line 80 and download this file in the same folder on your computer with the durham_crashes.geojson file to see the map in action.
<!DOCTYPE html>
<html>
<head>
<style>
html,
body {
font-family: Arial, sans-serif;
height: 100%;
margin: 0;
padding: 0;
<!DOCTYPE html>
<html>
<head>
<style>
html,
body {
font-family: Arial, sans-serif;
height: 100%;
margin: 0;
padding: 0;
<p id="notice"><%= notice %></p>
<p>
<strong>Title:</strong>
<%= @topic.title %>
</p>
<p>
<strong>Description:</strong>
<%= @topic.description %>
<%= form_for(@topic) do |f| %>
<% if @topic.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@topic.errors.count, "error") %> prohibited this topic from being saved:</h2>
<ul>
<% @topic.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<h1>New Topic</h1>
<%= render 'form' %>
<%= link_to 'Back', topics_path %>