Skip to content

Instantly share code, notes, and snippets.

require 'csv'
template = "Year: %{Year}, Make: %{Make}, skip Model,Description,Price"
rows = <<CSV
Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00
1996,Jeep,Grand Cherokee,"MUST SELL!"
CSV
activemodel (4.2.4) lib/active_model/attribute_methods.rb:433:in `method_missing'
representable (2.3.0) lib/representable/deserializer.rb:37:in `demarshal'
representable (2.3.0) lib/representable/deserializer.rb:32:in `block in deserialize'
representable (2.3.0) lib/representable/binding.rb:123:in `evaluate_option'
representable (2.3.0) lib/representable/deserializer.rb:31:in `deserialize'
representable (2.3.0) lib/representable/deserializer.rb:24:in `call'
representable (2.3.0) lib/representable/populator.rb:35:in `deserialize'
representable (2.3.0) lib/representable/populator.rb:21:in `call'
representable (2.3.0) lib/representable/binding.rb:88:in `read_fragment'
representable (2.3.0) lib/representable/binding.rb:67:in `block in uncompile_fragment'
{"utf8"=>"✓",
"authenticity_token"=>"0yIy7LDtbQBarrBz1pRZvjhibYw+Er+p+1YrNY1Hw7Wi7rTkF+tvsL5xWBuw/t2g/okz1+dPW34Me5iaaKhxpQ==",
"workflow"=>{"name"=>"klklk",
"steps"=>[{"user"=>{"id"=>"2"},
"form"=>{"id"=>"1"}}]},
"commit"=>"Create Workflow"}
class Create < Trailblazer::Operation
include Model
model Workflow
contract do
property :name
property :description
collection :steps, populate_if_empty: Step do
property :form, populate_if_empty: lambda { |params, *| Form.find(params[:id]) }
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<p>Test loaded and ready to fire, plase click left mouse button and follow the instructions on screen</p>
<script>
var body = document.getElementsByTagName("BODY")[0];
require 'json-schema'
form_schema = {
definitions: {
# label field
label: {
type: 'object',
properties: {
type: {
type: 'string',
// esempio form serializzata
[
{type: 'label', title: 'Subject name', description: 'The name of the subject'},
{type: 'label', title: 'Subject surname'},
{type: 'text', title: 'Notes'}
{
type: 'vector',
content:
[
{type: 'label', title: 'Feature'}
@stoffie
stoffie / solo.rb
Last active October 11, 2015 15:34
solo ruby template engine
module Solo;
module HTML
attr_reader :indent
attr_reader :indent_string
def self.define_element (tag)
define_method tag.to_sym do |*args, &b|
add_tabs
@output += "<"+ tag + ">"

Classificatore Lineare

Damiano Stoffie 166312

Natura del problema

Vogliamo produrre un programma la cui esecuzione puo essere separata in 2 momenti distinti: una fase di apprendimento supervisionato e una fase di esecuzione. Durante la fase di apprendimento supervisionato il programma riceve in input coppie etichettate di esempi e soluzioni. Il programma deve internalizzare queste coppie mediante un algoritmo che simuli un processo di apprendimento e produrre una funzione che sara' usata durante la fase successiva, per associare ad un input un output corretto. In particolare, nel caso di un classificatore lineare durante la fase di apprendimento l'algoritmo esamina un vettore e un valore booleano, alla fine dell'apprendimento vogliamo sia prodotta una funzione booleana definita nella maniera seguente:

f(X) = if  X * W >= a then true else false

Si tratta di identificare, con X coppia di punti, una retta che divida quanto meglio possibile gli esempi che sono ettichettati come veri da quelli e

# Ubuntu (last tested on Trusty Tahr (14.10.1), with Gosu 0.8.6)
# Gosu's dependencies for both C++ and Ruby
# sudo apt-get install build-essential libsdl2-dev libsdl2-ttf-dev libpango1.0-dev \
# libgl1-mesa-dev libfreeimage-dev libopenal-dev libsndfile-dev
# To install Ruby - if you are using rvm or rbenv, please skip this step
# sudo apt-get install ruby-dev
# If you are using rvm or rbenv, do not use 'sudo'