Skip to content

Instantly share code, notes, and snippets.

.ghx-controls-filters, .ghx-qty, .ghx-issue-fields .ghx-key, .ghx-card-footer .ghx-type, .ghx-card-footer .ghx-flags, .ghx-card-footer .ghx-end, .ghx-card-footer .ghx-days, #announcement-banner {
display: none!important;
}
#ghx-pool-column {
padding: 0 20px;
}
.ghx-issue .ghx-highlighted-fields .ghx-highlighted-field {
max-width: none;
function trackClick(name) {
if (!name) throw "track needs a name";
ga.track(name);
}
questions_so_far = []
answers_so_far = []
@app.route('/')
def index():
global questions_so_far, answers_so_far
question = request.args.get('question')
answer = request.args.get('answer')
questions = {
1: 'Is your character yellow?',
2: 'Is your character bald?',
3: 'Is your character a man?',
4: 'Is your character short?',
}
characters = [
{'name': 'Homer Simpson', 'answers': {1: 1, 2: 1, 3: 1, 4: 0}},
{'name': 'SpongeBob SquarePants', 'answers': {1: 1, 2: 1, 3: 1, 4: 0.75}},
def calculate_character_probability(character, questions_so_far, answers_so_far):
# Prior
P_character = 1 / len(characters)
# Likelihood
P_answers_given_character = 1
P_answers_given_not_character = 1
for question, answer in zip(questions_so_far, answers_so_far):
P_answers_given_character *= max(
1 - abs(answer - character_answer(character, question)), 0.01)
def calculate_probabilites(questions_so_far, answers_so_far):
probabilities = []
for character in characters:
probabilities.append({
'name': character['name'],
'probability': calculate_character_probability(character, questions_so_far, answers_so_far)
})
return probabilities
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Bayer Akinator</title>
</head>
<body id="home">
{% if result %}
<h1>You are thinking of {{ result }}!</h1>
{% else %}
from flask import Flask, render_template, request
# we will need those imports later
import random
import numpy as np
app = Flask(__name__)
@app.route('/')
def index():
const express = require('express');
const server = express();
const request = require('request');
const proxy = require('http-proxy-middleware');
server.set('view engine', 'ejs');
const createProxy = (path, target) =>
server.use(path, proxy({ target, changeOrigin: true, pathRewrite: {[`^${path}`]: ''} }));
@rogeriochaves
rogeriochaves / pipe.hs
Created November 24, 2015 01:02
pipe operator in haskell, very simple
x |> f = f x
something x = repeat x
|> filter (> 3)
|> map (+ 1)
|> take 5