venerdì 19 giugno 2009

Git in Gedit

Uno stumento veramente comodo ed efficace per il versionamento è l'ormai famoso e diffuso Git.

Utilizzando come IDE Gedit adeguatamente potenziato (qualche plugin qua e là, nulla di che) mi trovo veramente bene e l'unica mancanza finora era la possibilità di una integrazione con Git.
Partendo da questo post ho scelto di crearmi alcuni semplici script da utilizzare con il plugin Tools Extension, già ampiamente sfruttato.

Premessa
tutti questi comandi fanno riferimento al file attivo in gedit al momento del loro invio quindi bisogna prestare attenzione al file aperto al momento del loro utilizzo. L'istallazione del plugin è facilmente recuperabile in rete, per esempio qui, quindi la considero già fatta.
Per quanto riguarda Git presuppongo che sia già istallato e il repository inizializzato.

Questa è l'interfaccia del plugin richiamabile da:

Strumenti>Strumenti esterni...

Creazione procedura
Clicchiamo su New specificando il nome (a volte non lo prende, non preoccupatevi basta tornare successivamente a personalizzarlo)

Aggiungiamo una descrizione che ci aiuti in Description.

In Accelerator indichiamo il tasto scorciatoia (tutti i comandi saranno disponibili nel menu Strumenti)

In Commands incolliamo lo script che ci interessa

In Inputs scegliamo Nothing
In Output scegliamo 'Display in bottom panel'
In Applicability scegliamo 'All Documents'

L'output dell'esecuzione dei comandi viene visualizzato nella finestra inferiore "Output della shell" visualizzabile con Ctrl+F9

SCRIPT

Commit del file nel branch attivo
#!/bin/sh
# Ask message for commit
COMMIT_MESSAGE=`zenity --text-info --editable --width=500 --title="Commit message - gedit" --text="Insert commit message for this file"`
# add current file into repository
git add "$GEDIT_CURRENT_DOCUMENT_NAME"
# Commit current file with previous message
git commit -m "$COMMIT_MESSAGE"
# Print git status
git status

Commit di tutti i file modificati nel branch attivo
#!/bin/sh
# Ask message for commit
COMMIT_MESSAGE=`zenity --text-info --editable --width=500 --title="Commit message - gedit" --text="Insert commit message"`
# add all files into repository
git add .
# Commit current file with previous message
git commit -m "$COMMIT_MESSAGE"
# Print git status
git status


Cambio branch
#!/bin/sh
# Ask name of branch to change
NEW_BRANCH=`zenity --text-info --editable --width=500 --title="New branch - gedit" --text="Insert the name of new current branch"`
# change branch
git checkout "$NEW_BRANCH"
# Print git status
git status

Caricamento branch"sviluppo" sul master
#!/bin/sh
# Ask name of branch to add to master
NEW_BRANCH=`zenity --text-info --editable --width=500 --title="Branch to add - gedit" --text="Insert the name of branch to add"`
# change branch
git checkout master
git merge "$NEW_BRANCH"
# Print git status
git status

Ovviamente ogni script ha bisogno di una sua procedura :-)
Buon versionamento!

venerdì 22 maggio 2009

A rdoc collection auto-updated

Ever more applications hosted by git hub without documentation updated on-line !

http://rdoc.info/

A simple and really useful service that allows you to always have updated the documentation without having to regenerate every time.

Just click on the update button at the top to make sure that the documentation is up to date and a link back to the corresponding page github

doc of ActiveWarehouse

doc of ActiveWarehouse-etl

A little step by step building AW

A very simple guide to bild a basic RoR application with ActiveWarehouse e ActiveWarehouse-etl

the application

a simple italian guide

venerdì 20 febbraio 2009

Getting started with Activewarehouse: documentation and examples

I began to discover these gems
ActiveWarehouse
ActiveWarehouse-etl

and the first problem was to put together some documentation and examples

an important introduction
a presentation and the code
another presentation

activewarehouse:
rdoc (documentation dated, regenerate it locally rake doc:plugin)
readme

a demo application (github rails 1.1.6) (svn link)
tutorial (via web archive)
a important change

activewarehouse-etl:
the first
ctl examples: 1, 2, 3

the 2 blog of developpers:
http://blog.anthonyeden.com/
http://martyhaught.com/

This is only a first collection and I hope to update it thanks to feedback
Will soon try to write a brief account of my step-by-step experiments

mercoledì 17 dicembre 2008

Line graph with error band

Example of line graph with error band.
The function draws a series of quadrilaterals whose vertices matched pairs of the two series data_up and data_down then inserting a line is the average values.
To actually use series with variable error just simply change the code by passing the three sets as parameters instead generate randomly.


test_it_controller.rb

class TestItController < ApplicationController
def index
@graph1 = open_flash_chart_object(600,300,"/test_it/graph1_code")
end

def graph1_code

title = Title.new("a Graph")

chart = OpenFlashChart.new
chart.set_title(title)

@data_up = [1]
@data_down = [-1]

0.step(30, 1) {|i|
@data_up << @data_up[i] +rand - 0.5
@data_down << @data_down[i] + rand - 0.5
}

def draw_quadri(i)
q = Shape.new( '#80B11A' )
q.append_value(ShapePoint.new(i,@data_up[i]))
q.append_value(ShapePoint.new(i,@data_down[i]))
q.append_value(ShapePoint.new(i+1,@data_down[i+1]))
q.append_value(ShapePoint.new(i+1,@data_up[i+1]))
return q
end

flux = []
(@data_up.length-1).times do |h|
flux << draw_quadri(h)
end

flux.each do |shape|
chart.add_element(shape)
end

scatter_line = ScatterLine.new( '#FF0000', 5 )
scatter_line_u = ScatterLine.new( '#FF0000', 3 )
scatter_line_d = ScatterLine.new( '#FF0000', 3 )
data = []
data_u = []
data_d = []

x=0
(@data_up.length).times do |h|
data << (ScatterValue.new(x,(@data_up[h] + @data_down[h])/ 2))
data_u << (ScatterValue.new(x,@data_up[h]))
data_d << (ScatterValue.new(x,@data_down[h]))
x+=1
end

scatter_line.set_values(data); chart.add_element(scatter_line)
scatter_line_u.set_values(data_u); chart.add_element(scatter_line_u)
scatter_line_d.set_values(data_d); chart.add_element(scatter_line_d)

x = XAxis.new
x.set_range(0,32,5)
x.set_offset(false)
chart.set_x_axis(x)

y = YAxis.new
y.set_range(-5,5,1)
y.set_offset(true)
chart.set_y_axis(y)

render :text => chart.to_s
end
end

giovedì 11 dicembre 2008

Radar chart lines

First attempt to offer something to my referring to the excellent tutorial by pullmonkey.com and harryseldon
here is the ruby in transposition of the third example of radar chart
radar chart lines

test_it_controller.rb

class TestItController < ApplicationController
def index
@graph1 = open_flash_chart_object(600,300,"/test_it/graph1_code")
end

def graph_code
chart = OpenFlashChart.new
chart.set_title(Title.new('Radar Chart'))

values = [30,50,60,70,80,90,100,115,130,115,100,90,80,70,60,50]
spokes = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p']
vals = []

values.each_with_index do |value, i|
tmp = DotValue.new( value, '#D41E47' )
tmp.set_tooltip("#val#&ltbr%rtSpoke: #{spokes[i]}")
vals.push(tmp)
end

line = LineHollow.new()
line.set_values( vals )
line.set_halo_size( 0 )
line.set_width( 2 )
line.set_dot_size( 6 )
line.set_colour( '#FBB829' )
line.set_key( 'Hearts', 10 )
line.loop()


# add the area object to the chart:
chart.add_element(line)

r = RadarAxis.new( 150 )
r.set_steps(10)
r.set_colour( '#DAD5E0' )
r.set_grid_colour( '#EFEFEF' )
chart.set_radar_axis( r )

tooltip = Tooltip.new()
tooltip.set_proximity()
chart.set_tooltip( tooltip )

chart.set_bg_colour( '#ffffff' )

render :text => chart.to_s
end
end