Skip to content

Instantly share code, notes, and snippets.

View perceptron.py
import numpy as np
class Perceptron(object):
"""Perceptron classifier
Parameters
----------
eta : float
Learning rate (between 0.0 and 1.0)
n_iter : int
View simple_interactive_interpreter.rb
# 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 Jan 6, 2016
Twitter Scraping Job for Dashing
View twitter_scraper.rb
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 Jan 10, 2019
12 Hour Clock for Dashing
View README.md

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
View knockout.cleditor.js
(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 Jul 31, 2012
Ruby CLI Progress Indicators
View progress_indicators.rb
# 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 '/'