Skip to content

Instantly share code, notes, and snippets.

View andrewdanks's full-sized avatar

Andrew Danks andrewdanks

View GitHub Profile
type Perceptron
learning_rate
threshold
weights::Array{Float64, 1}
max_iters::Integer
function Perceptron(num_units::Integer=1, threshold::Float64=0.0, learning_rate::Float64=0.1, max_iters::Integer=1000)
weights = init_weights(num_units)
new(learning_rate, threshold, weights, max_iters)
end
@andrewdanks
andrewdanks / cool_story_bro.py
Last active May 7, 2022 18:08
"Cool story, bro" alternatives
from itertools import product
from random import choice
# Cool story, bro. alternatives
# by @andrewdanks
# Prints all combinations iff True; prints a random sentence otherwise.
print_all_combos = False
story_adjectives = ['intriguing', 'riveting', 'gripping', 'fascinating', 'compelling', 'charming', 'dazzling']
@andrewdanks
andrewdanks / utils.js
Created October 2, 2012 03:47
A simple utility function for rendering a sequence of templates in express for node.
/*
A simple utility function for rendering a sequence of templates in express for node.
Usage:
var utils = require('./utils');
utils.renderTemplates(res, ['header', 'about', 'footer'], {title: 'About'});
*/
module.exports.renderTemplates = function(res, templates, params, callback, error_callback) {
// By default we just send the html in the response
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby