Archive for the ‘Programmierung’ Category.

Bilder mit lpic beschriften

Mit dem neuen lpic Paket (TeXLive hat es schon, MikTeX meines Erachtens noch nicht) lassen sich recht einfach Bilder nachträglich beschriften. Hier ein Beispiel:

\documentclass{scrartcl}
\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[]{lpic}
\author{Uwe Ziegenhagen}
\title{}
\begin{document}
 
\begin{figure}
\centering
\begin{lpic}[grid,coords(20)]{Arduino}
\lbl[t]{12,40;\textcolor{green}{\small \textbf{USB-Port}}}
\lbl[t]{19,20;\textcolor{green}{\textbf{9--12V}}}
\lbl[t]{55,20;\textcolor{green}{\textbf{ATMega 328}}}
\end{lpic}
\caption{Arduino Duemilanove}
\end{figure}
\end{document}

Benötigt wird noch die Datei Arduino.pdf

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

CorelDraw Datei für den Arduino

Basierend auf den SVG Dateien aus Fritzing hier eine CorelDraw X4 Datei, die auf einzelnen Ebenen die einzelnen Bestandteile des Arduinos hat.

Arduino

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Powershell und SQL – INSERT

Auf http://richardspowershellblog.wordpress.com/2007/04/19/insert-values-to-a-sql-server-table/ habe ich ein kurzes Statement gefunden, um per Powershell Einträge in einer SQL Datenbank vorzunehmen.

# open connection to the server
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=localhost; Initial Catalog=Posh; Integrated Security=SSPI")
$conn.Open()
 
# create command object
$cmd = $conn.CreateCommand()
# create statement
$cmd.CommandText ="INSERT myTable VALUES ('Hello', 'World', 123)"
# execute command
$cmd.ExecuteNonQuery()
# close connection
$conn.Close()

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Powershell und SQL Insert

Auf http://richardspowershellblog.wordpress.com/2007/04/19/insert-values-to-a-sql-server-table/ habe ich ein kurzes Statement gefunden, um per Powershell Einträge in einer SQL Datenbank vorzunehmen.

# open connection to the server
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=localhost; Initial Catalog=Posh; Integrated Security=SSPI")
$conn.Open()
 
# create command object
$cmd = $conn.CreateCommand()
# create statement
$cmd.CommandText ="INSERT myTable VALUES ('Hello', 'World', 123)"
# execute command
$cmd.ExecuteNonQuery()
# close connection
$conn.Close()

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Google Visualisation API mit R nutzen

Mit googleVis gibt es ein interessantes Paket für R, mit dem man aus R heraus die Visualisierungs-API von Google nutzen kann.

http://code.google.com/p/google-motion-charts-with-r/

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

E-Mails mit personalisierten Attachments versenden

Vor kurzem hatte ich die dankbare Aufgabe, mehrere hundert E-Mails mit personalisierten Anhängen (im PDF-Format) zu versenden. Da auf die Schnelle kein Tool bereitstand, das bei dieser Aufgabe helfen konnte, musste etwas Selbstentwickeltes her.

Teil 1 der Aufgabe bestand darin, aus der PDF-Gesamtdatei jeweils zwei Seiten zu extrahieren und abzuspeichern. In einer Excel standen glücklicherweise die Namen der Kunden sowie die Kunden-ID. Die Exceldatei habe ich dann als CSV exportiert (man hätte die Excel-Datei sicher auch direkt lesen können) und ein Powershellskript für PDFTK geschrieben.

# Uwe Ziegenhagen, 20101207
 
# read addresses, tab-delimited
$entries = Import-Csv -Delimiter "`t" c:\adresses.txt
# change to directory of PDF pages
cd c:\Email_Sende_Aktion\
# user counter variable ($i contains an object)
$j = 0
foreach ($i in $entries){
$j = $j +1 
# take filename of new PDF from CSV
$filename = $i.addressid + ".pdf"
# calculate pages to be extracted
$pagestoextract = "A" + $j + "-" + ($j+1)
# call pdftk
pdftk A= bigserialletter.pdf cat $pagestoextract output $filename 
$j = $j +1 
}

Teil 2 der Aufgabe bestand dann darin, jedem Kunden eine E-Mail mit seinem Attachment zu schicken, kein Kunde sollte ein PDF erhalten, das nicht für ihn bestimmt war. Dank Powershells „send-mailmessage“ ließ sich das auch recht einfach umsetzen.

# generate Encoding object for UTF8 (no äüö otherwise)
$encoding = [System.Text.Encoding]::UTF8
 
# Import email addresses and fund ids
$files = Import-Csv -Delimiter "`t" c:\Email_Sende_Aktion\adresses.txt
 
# read mail body, preserve line breaks
# http://www.eggheadcafe.com/software/aspnet/33110753/passing-a-string-with-linebreaks-to-a-com-object.aspx
$body  = [io.file]::ReadAllText("c:\Email_Sende_Aktion\mailbody.txt")
 
# just a counter for checking
$t = 0;
foreach ($i in $files){
	# inc counter
	$t = $t +1
	# cat body from the different parts
	$usedbody = "Sehr geehrte/r " + $i.Anrede.Trim() + ". " + $i.Nachname.Trim() + "," + $body 
	# find the individual attachment based on addressid
	$file = "c:\Email_Sende_Aktion\" + $i.addressid + ".pdf"
	# send message
	 send-mailmessage -Encoding $encoding -From me@me.com -BCC notme@me.com -To $i.RealMail -Subject "Kundeninformation Foobar"  -Body $usedbody -Smtpserver nameofexchangeserver -Attachments  $file
	$t
}

English summary: If you have no dedicated tool to send personalized PDF-attachments via e-mail, you can easily use Powershell to generate theses e-mails. Part 1 of the task consisted of splitting a big PDF file with all serial letters into 2-page pieces, task 2 of sending the e-mails to the recipients.

Keywords: Powershell, Outlook, Attachment, PDF

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Hallo Welt mit iTextSharp

Heute habe ich mir mal die iTextsharp.dll von Sourceforge geladen, um aus C# heraus mal eine PDF Datei zu erzeugen. Im Visual Studio Projekt muss dann nur ein Verweis auf diese DLL erstellt werden, dann sollte das folgende Beispiel problemlos laufen. Ausgehend von diesem Beispiel werde ich mal schauen, ob man das nicht für was Sinnvolles einsetzen kann.
Ist sicher kein Ersatz für LaTeX, ein paar Dinge könnte ich mir jedoch vorstellen… 🙂

using System.IO;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Document pdfDocument = new Document();
            PdfWriter.GetInstance(pdfDocument, new FileStream("C:\\hallo.PDF", FileMode.Create));
            pdfDocument.Open();
            pdfDocument.Add(new Paragraph("Ich bin ein Absatz"));
            pdfDocument.Close();
        }
    }
}

Auch aus Powershell heraus lässt sich iTextsharp nutzen: http://www.powershell.nu/2009/09/08/scripting-pdf-documents-through-powershell/

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Rainbowduino vom Arduino aus steuern

Ein weiteres Ergebnis des Bastelabends in der Dingfabrik waren die ersten Gehversuche mit dem Rainbowduino.

In der jetzigen Version steuert der Arduino über die serielle Schnittstelle den Rainbowduino, Details folgen.

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

RFID mit dem Arduino

Letzten Freitag beim Bastelabend in der Dingfabrik, haben wir mit dem RFID ID-12 von Watterott rumgespielt, die Konfiguration war recht einfach.

Informationen gab es hier:

Die Software konnte ich 1:1 auf den Arduino übernehmen, hier noch ein paar Bilder:

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

PWM mit dem Arduino

Schon lang auf der TODO-Liste habe ich heute mal per PWM meine RGB-LED dimmen lassen. PWM steht für Pulsweitenmodulation, ein Verfahren, das es ermöglicht, analoge Signale mit digitalem Output zu erhalten. Gut beschrieben ist es in http://www.arduino.cc/en/Tutorial/PWM.

Als Codebasis habe ich das Beispiel von http://www.arduino.cc/en/Tutorial/DimmingLEDs genommen.

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website