Blog

Watt'n ditte?

Etwas, das kein Blog ist, dennoch Artikel enthält, kein Newsfeed ist, dennoch Neuigkeiten integriert und auch keine Müllhalde ist, und trotzdem meine Meinung in sich birgt. Ich nenne es: Blnemü... Na ja, das werde ich vor dem Veröffentlichen noch ändern.
Interessiert dich alles nicht? Dann rasch weiter zum Beschwerde-Formular!
Seite benötigt Sarkasmusdetektor-Addon.
Sofern nicht anders angegeben, stehen alle Bilder unter: CC BY 4.0.

Archiv: 2024 2023 2022 2021 2020 2019 2018 2017 2016 2015 | Gallery |

03.11.2015 - Durchbruch in der Bienenforschung: 650bee

Auch, wenn man nur eine brennende Forschungsstadt ist, kann man dennoch Forschungsergebnisse präsentieren:
650bee - Es sind Stinklinien, keine Summlinien!

Eigenschaften der 650bee

  • Langsamer und fetter, als die Twosixerbee, wenn auch nicht so schlimm, wie die Twentyninerbees, die schon tot zur Welt kommen
  • Wird sexuell angezogen von: Feuer, Säure, Gammastrahlung und den Christdemokraten
  • Sie pflanzt sich fort, in dem sie ihre Eier im Kopf von ihrem Besitzer ablegt, wo sie auch befruchtet werden ("Kopp-Snu-Snu") – die Larven ernähren sich vom Gedächtnis und dem Sprachzentrum
  • Anders als die Twosixerbee, entwickelt sich die 650bee nur in extrem seltenen Einzelfällen zur Konkubiene weiter, wiegt dann jedoch mindestens 600 Pfund und riecht nach Lulu
  • Wie normale, menschliche Bienen beherrscht sie den Bienentanz, sie zieht jedoch beim Tanzen eine Feuerspur hinter sich her – vermutlich benutzen die 650bees dies, um ihren Artgenossen mitzuteilen, dass die Wiese brennt
  • Wenn sie nicht so dumm wäre, würde sie alle töten, die du liebst – allerdings würde sie dann GRRMwasp heißen
(BTW: Es sind Stinklinien, keine Summlinien)

23.10.2015 - Attila the Huhn

Attila the Huhn Attila the Huhn (413 – 453) unternahm wiederholt Kriegszüge, die oft mit großem Scharren durchgeführt wurden und sich zunächst gegen das Oströmische Reich, ab 451 dann gegen das Weströmische Reich richteten. Er zielte vor allem darauf ab, möglichst hohe Tributzahlungen der Römer durchzusetzen, es wird je nach Quellen von anfangs 350 Pfund, zu später 700 Pfund, sowie unter Kaiser Theodosius von Einmalzahlungen von 6000 Pfund und Jahrestributen von 2100 Pfund Körnern berichtet.
Nachdem er die Siedlungen Hennickendorf, Körnersdorf und Hof Huhnstadt gegründet hatte, griff er im Spätsommer 451 die Franzosen, die damals noch nicht wussten, dass sie Franzosen waren und sich Gallier nannten, auf Katalaunischen Feldern an. Es ist bisher nicht bekannt, was passiert ist, aber da man nicht davon ausgehen kann, dass Franzosen irgendwas gewinnen, scheint es sicher, dass Vogelscheuchen aufgestellt wurden oder ein Bündnis mit Füchsen eingegangen wurde, die das ganze Gänseregiment von Attila the Huhn stahlen.
Weil er sich auch mal wieder waschen wollte, was in Frankreich unmöglich ist, zog sich Attila the Huhn nach der Schlacht zurück und starb in seiner Hochzeitsnacht bei Snu-Snu mit einem heißen Chick.

Damit so etwas nicht wieder passiert, werden seit dem alle Hühner in Legebatterien gefangen gehalten. Leider kann heutzutage so gut wie niemand mehr Attilas Namen richtig schreiben und fast jeder hält ihn fälschlicherweise für einen Menschen.

Zitate von Attila the Huhn

Das Huhn wird sich schon quetschen, um raus zu kommen; Draußen isses ja geil!
(Offensichtlich eine tiefschürfende Metapher - Irrtümlich Fynn Kliemann zugeschrieben)

Du bist ein Huhn!
(Zu Marcy)

Was willst du denn, du Vogel?
(Zu Kaiser Theodosius)

Fliegt meine Süßen, fliegt!
(Beim Angriff auf Legio XLVII)

Wenn das allmächtige Spaghettimonster mir noch ein Leben schenkt, so will ich es so weit bringen, dass es kein Huhn in meinem Königreich gibt, das nicht imstande ist, sonntags einen Bauern in seinem Topf zu haben.
(Zu einer Hugenutte am Hafen von Amiens)

Sie mögen uns die Federn nehmen, aber niemals nehmen sie uns, unsere Körner!
(Später von William Wallace geklaut)

Hört auf, wegzulaufen, diese Feigheit wird uns ewig nachhängen!
(Zu seinen Truppen bei der Schlacht um die Katalaunischen Felder)

Extract version-numbers from Lazarus project files (.lpi) using bash

Extracting is quite simple, 'cause Lazarus uses XML for the version-numbers so gathering the data is done by 4 simple lines of code. The remaining lines are for handling the extracted data, 'cause Lazarus removes the nodes if for example the major-version is 0 (which is smart, cause it saves data):
getversion.sh
#!/bin/bash ################################################################################################################ # Version 0.1.0.1 ################################################################################################################ #excample of datastructure in lpi-files (xml): #<MajorVersionNr Value="1"/> #<MinorVersionNr Value="2"/> #<RevisionNr Value="1"/> #<BuildNr Value="75"/> #Variables: File=$1 if [ "$File" = "" ]; then #exit if empty parameter to fix "hang-bug" exit fi function ZeroIfEmpty #function returns 0 if parameter (which should be a version numer) is empty { if [ "$1" = "" ]; then echo 0 else echo $1 fi } #Gather the data: Major=( $(grep -oP "<MajorVersionNr\ Value=(.*)" $File | cut -d '"' -f 2 | cut -d '"' -f 1) ) Minor=( $(grep -oP "<MinorVersionNr Value=(.*)" $File | cut -d '"' -f 2 | cut -d '"' -f 1) ) Revision=( $(grep -oP "<RevisionNr Value=(.*)" $File | cut -d '"' -f 2 | cut -d '"' -f 1) ) Build=( $(grep -oP "<BuildNr Value=(.*)" $File | cut -d '"' -f 2 | cut -d '"' -f 1) ) #Lazarus removes the nodes with versionnumbers, which are 0, so if we received empty values, we've to set them to 0: Major=( $(ZeroIfEmpty $Major)) Minor=( $(ZeroIfEmpty $Minor)) Revision=( $(ZeroIfEmpty $Revision)) Build=( $(ZeroIfEmpty $Build)) #Output: echo $Major.$Minor.$Revision.$Build

Using the script in your code is also very simple, for example writing the version to a file:
getversion.sh "$ProjectsLPI" > "$Versionfile" $ProjectsLPI is the path to your project's lpi-file
$Versionfile is the file you want to get the version-numbers

Used software:
bash 4.3.30
grep 2.20
cut (GNU coreutils) 8.23

05.09.2015 - HTML2RSS

Problem to solve: Create an RSS-feed on Linux.
Here's my path to the solution:

1. Have I done it before?

Kind of, but it isn't able to run on Linux, not even with wine Wine.

2. Can I port it?

Probably yes, but it would take a lot of time, particularly if that VCL-XML-stuff was a Windows-only-thing and as far as I remember, it was.

3. Has somebody else done it before?

After a couple of minutes of research: Not as binary, especially not for Linux. But before I could continue the search, I found some code-snippets of a user who tried to parse something by using lynx and the bash.
"God ol' bash", I though, "It is more powerful than I know!"
After a bunch of minutes, I had a working piece of code which was able to extract the article-title-lines of my blog-thingy and store it into an array. Of course, I lost quite some time *cough*hours*cough* struggling with bash's syntax (I'm not using it often), but I also added the parsing of some other informations (IDs, dates) and finally I was able I to put it into a rss-xml-structure for a rss-feed.
It's obviously optimized for my own implementation of informations into html5, so it might be not simply useful for all other HTML-pages of other people (without changes). Especially if they're cooking div-soups or using tables for layout.
But it can lead the way to a script that works for you.

createrssfeed.sh #!/bin/bash ################################################################################################################ # Version 0.1.1.2 ################################################################################################################ LocalWebsite=/media/truecrypt1/Websites/lafin.de/undsonst_2015.html Website4Link=http://lafin.de/undsonst_2015.html# RSSFile=/media/truecrypt1/Websites/lafin.de/rss/newsfeed.xml Debug=1 #set to 0 to disable debug-output (to much lines to disable 'em with comments) #xml-stuff: Title='Lafin.de Newsfeed' Link='http://lafin.de' Description='Newsfeed für Lafin.de (Newsfeed for Lafin.de - Mostly German, but important stuff also in English)' Language=de ################################################################################################################ IFS=$'\n' #to fix blankes-create-new-"array-row"-bug #Parse (whole) titles: ArrayRawTitles=( $(grep -oP "<h2>(.*)</h2>" $LocalWebsite | cut -d ">" -f 2 | cut -d "<" -f 1) ) #Parse IDs: ArrayArticleIDs=( $(grep -oP "<a(.*)href=(.*)</h2>" $LocalWebsite | cut -d "#" -f 2 | cut -d "\"" -f 1) ) #check, if the hypertext got parsed correctly and every title got an ID: if [! ${#ArrayArticleIDs[@]} = ${#ArrayArticleIDs[@]} ]; then echo "Error, arraysize doesn't match: ${#ArrayRawTitles[@]} <> ${#ArrayArticleIDs[@]}" exit 1 fi #skip article-code-template: if [ "${ArrayRawTitles[0]}" = "CAPTION" ]; then i=1 else i=0 fi #Write the RSS-File #write header: echo > $RSSFile '<?xml version="1.0" encoding="UTF-8"?>' #> = creates new file-content, while >> = append echo >> $RSSFile '<rss version="2.0">' echo >> $RSSFile '' #empty line for readability echo >> $RSSFile '<channel>' echo >> $RSSFile '<title>'$Title'</title>' echo >> $RSSFile '<link>'$Link'</link>' echo >> $RSSFile '<description>'$Description'</description>' echo >> $RSSFile '<language>'$Language'</language>' for ((; i < ${#ArrayArticleIDs[@]}; i++ )) #for each ID new RSS-item do #Debug-Stuff: if [ $Debug = 1 ]; then echo "${ArrayArticleIDs[$i]}" #id-format=27101885 (27th oct 1885) echo "${ArrayRawTitles[$i]}" #whole title, includes date at the beginning for the most time, but that's not needed in rss-feeds, so we cut it in the next line echo "${ArrayRawTitles[$i]}" | sed -e 's#^[0-9]*.[0-9]*.[0-9]* - ##' #cut off date at the title-beginning #Convert ID to a date for use in pubDate later: TempDate=`echo "${ArrayArticleIDs[$i]}" | awk '{ print substr($0,5,4)substr($0,3,2)substr($0,1,2) }'` echo `LANG=en_us_88591 date -d"$TempDate" +"%a, %d %b %Y 00:00:00 +0200"` fi #write entries: echo >> $RSSFile '' #empty line for readability echo >> $RSSFile '<item>' TempString=(`echo "${ArrayRawTitles[$i]}" | sed -e 's#^[0-9]*.[0-9]*.[0-9]* - ##'`) echo >> $RSSFile '<title>'$TempString'</title>' echo >> $RSSFile '<link>'"$Website4Link""${ArrayArticleIDs[$i]}"'</link>' echo >> $RSSFile '<guid>'"$Website4Link""${ArrayArticleIDs[$i]}"'</guid>' echo >> $RSSFile '<pubDate>'`LANG=en_us_88591 date -d"$TempDate" +"%a, %d %b %Y 00:00:00 +0200"`'</pubDate>' echo >> $RSSFile '</item>' done #end for #write footer: echo >> $RSSFile '' #empty line for readability echo >> $RSSFile '</channel>' echo >> $RSSFile '</rss>' unset IFS #unset the blankes-bug-stuff

Used software:
bash 4.3.30
grep 2.20
cut, date (GNU coreutils) 8.23
awk 4.1.1
sed 4.2.2

14.03.2015 - A simple way to create link-files (not symlinks/softlinks nor hardlinks) in XFCE/Thunar

So I was searching for a way (Thunar-plugin or something like that) to create files, which link to a specified location (for example "/mnt/data/plans to the world domination/innocent seal plan.odt"), but symlinks weren't an option (reasons doesn't matter at this point – I simply wanted to have the lnk-files-functionality of Windows in Linux). Of course, I found no solution so far.

So I wrote a couple of bash-lines to open a location (stored in a file) by its default application:
run_links.sh #!/bin/bash ################################################################################################################ # Version 0.2.0.2 ################################################################################################################ Opencommand=thunar readarray -t Array_ContentOfLinkFile < "$1" for (( i = 0; i < ${#Array_ContentOfLinkFile[@]}; i++ )) do IFS=$'\n' #to fix cut at 1st blank Binary=( $(echo ${Array_ContentOfLinkFile[$i]} | cut -c 6- ) ) unset IFS #unset the cut-at-1st-blank-bug-stuff if [ `echo ${Array_ContentOfLinkFile[$i]} | cut -c 1-5` = '[BIN]' ]; then #if marked as binary $Binary & #open file as binary with parameters and stuff else $Opencommand "${Array_ContentOfLinkFile[$i]}" & #open file with default-program fi done This reads all lines of a file ($1) and gives them one by one to Thunar which will open each link with its standard application. It also supports URLs by opening them into your default browser. In previous versions, I was using xdg-open, which wasn't sometimes using my default applications, produced weird filenames on opened ODF-files and it was not able to run programs nor scripts. Thunar works better in all ways. If you want to run this on KDE or GNOME, try first using Nautilus or Dolphin instead of kde-open or gnome-open.
Why the multiple lines support? So I'm able to open a bunch of stuff with a single file. For example a software-project: You can open the projectfile, the directory and the documentation by just one linkfile.

So you're now able to open linkfiles, but you want to manually pasting stuff into a textfile and give it the .link extension every time? In case you don't want to, create this:
create_linkfile.sh #!/bin/bash if [ -n "$1" ]; then echo "$1" > "$1.link" fi The script simply puts a path ($1) into a file (filename = "path + filename + .link"). It's supposed to run by the "Thunar Custom Actions" (create_linkfile.sh %f): Right click a file or folder will run this script and creates a linkfile at the same location.

Finally, you can register your linkfile to the mime-system. Create an xml-file containing this:
linkfile-mimetyp.xml <?xml version="1.0"?> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-type type="text/x-linkfile"> <comment>Linkfile (no symlink nor hardlink)</comment> <glob pattern="*.link"/> </mime-type> </mime-info> then run: sudo xdg-mime install --mode system linkfile-mimetyp.xml If you want to use an icon (png) for that file, get one, name it linkfile-icon_128.png and run: sudo xdg-icon-resource install --context mimetypes --size 128 linkfile-icon_128.png text-x-linkfile (If you want to use 64x64 or 32x32pixel files, exchange 128 to 64 or 32).
For some reason, this works fine in Thunar and all file-browsing-windows, but not on the desktop. I didn't found a solution yet.

Used software:
Thunar 1.6.6
bash 4.3.30
XFCE 4.12

Update 10.9.2015
Version 0.2.0.2 of run_links.sh added: If you add [BIN]+Path (no spaces, for example "[BIN]/opt/Linproman/Linproman -gimmesteaks") to your linkfile, run_links.sh will run it as a binary (without any involving of Thunar/$Opencommand) and you'll be able to use parameters and stuff.

Archiv: 2024 2023 2022 2021 2020 2019 2018 2017 2016 2015 | Gallery |