Skip to content

Instantly share code, notes, and snippets.

import numpy as np
class Perceptron(object):
"""Perceptron classifier
Parameters
----------
eta : float
Learning rate (between 0.0 and 1.0)
n_iter : int
# A simple Ruby interpreter designed to evaluate mathematical expressions.
#
# USAGE:
# interpreter = Interpreter.new
# interpreter.input('1 + 1') => 2
# interpreter.input('2 - 1') => 1
# interpreter.input('2 * 3') => 6
# interpreter.input('8 / 4') => 2
# interpreter.input('7 % 4') => 3
# interpreter.input('x = 1') => 1
@jpo
jpo / twitter_scraper.rb
Created January 6, 2016 22:24
Twitter Scraping Job for Dashing
require 'nokogiri'
require 'open-uri'
# Retrieves publicly available tweets for a twitter account.
# This job is intended to be used with the comments widget.
# Config
# ------
twitter_username = ENV['TWITTER_USERNAME'] || '[TWITTER USERNAME]' # Do not include the @ symbol
twitter_avatar = '[TWITTER AVATAR URL]' # e.g. https://pbs.twimg.com/profile_images/...
@jpo
jpo / README.md
Last active January 10, 2019 05:10
12 Hour Clock for Dashing

Dashing - 12 Hour Clock

This widget displays the current time as a 12-hour clock.

Installation:

Open a shell and run this command from the root of your dashing project:

dashing install 6e2f80b4812c5b9474f3
(function () {
if (typeof (ko) === undefined) {
throw 'Knockout is required, please ensure it is loaded before loading this validation plug-in';
}
ko.bindingHandlers.cleditor = {
init: function(element, valueAccessor, allBindingsAccessor) {
var modelValue = valueAccessor(),
allBindings = allBindingsAccessor();
@jpo
jpo / progress_indicators.rb
Created July 31, 2012 02:23
Ruby CLI Progress Indicators
# Terminal Progress Indicators. Four examples are included: percentage,
# spinner, progress bar, and combined. This script has been tested on
# Mac OS X 10.8 with Ruby 1.8.7, 1.9.1, 1.9.2, and 1.9.3
class Spinner
include Enumerable
def each
loop do
yield '|'
yield '/'