<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Jollobajano</title>
  <link href="https://jollobajano.com/index.html"/>
  <link rel="self" href="https://jollobajano.com/feed.xml"/>
  <id>https://jollobajano.com/</id>
  <updated>2026-12-03T00:00:00Z</updated>
  <author><name>Mats Nyberg</name></author>
  <entry>
    <title>Atmega328p circuit</title>
    <link href="https://jollobajano.com/posts/embedded-baremetal/ATMega328P_circuit.html"/>
    <id>https://jollobajano.com/posts/embedded-baremetal/ATMega328P_circuit.html</id>
    <updated>2026-12-03T00:00:00Z</updated>
    <category term="embedded-baremetal" label="Embedded &amp; Bare Metal"/>
    <summary>En grundläggande, fristående (standalone) krets för en ATmega328P (DIP-28 kapsel) kräver bara ett fåtal externa komponenter för strömförsörjning, återställning och klockfrekvens. [1]…</summary>
    <content type="html">&lt;p&gt;En grundläggande, fristående (standalone) krets för en ATmega328P (DIP-28 kapsel) kräver bara ett fåtal externa komponenter för strömförsörjning, återställning och klockfrekvens. [1] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/), [2] (https://www.youtube.com/watch?v=qGbuzuVSzVs)&lt;/p&gt;
&lt;p&gt;Nödvändiga komponenter&lt;/p&gt;
&lt;p&gt;• Mikrokontroller. 1x ATmega328P-PU (28-pinnars DIP).
• Pull-up-motstånd. 1x 10 kΩ motstånd (för RESET).
• Avkopplingskondensatorer. 2x 100 nF (0,1 µF) keramiska kondensatorer.
• Klockkristall (valfritt). 1x 16 MHz kristall + 2x 22 pF keramiska kondensatorer (behövs endast om du inte använder den interna 8 MHz-oscillatorn).
• Återställningsknapp (valfritt). 1x tryckknapp (momentan). [1] (https://www.youtube.com/watch?v=gtij4ecuVgk), [2] (https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf), [3] (https://www.instructables.com/Stand-Alone-Arduino-ATmega328p/), [4] (https://rheingoldheavy.com/arduino-from-scratch-part-12-atmega328p-schematic-and-headers/), [5] (https://www.youtube.com/watch?v=qGbuzuVSzVs), [6] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)&lt;/p&gt;
&lt;p&gt;Kopplingsschema (Pin-för-pin)&lt;/p&gt;
&lt;p&gt;Funktion    Pin på ATmega328P   Anslutning
Strömförsörjning (+)    Pin 7 (VCC) &amp;amp; Pin 20 (AVCC) Anslut båda till +5V (eller +3,3V vid 8 MHz).
Jord (-)    Pin 8 (GND) &amp;amp; Pin 22 (GND)  Anslut båda till GND.
Avkoppling  Mellan Pin 7–8 och Pin 20–22    Placera en 100 nF kondensator så nära respektive par som möjligt för att filtrera brus.
Reset   Pin 1 (RESET)   Anslut till +5V via ett 10 kΩ motstånd. För manuell reset, koppla en tryckknapp mellan Pin 1 och GND.
Extern klocka   Pin 9 (XTAL1) &amp;amp; Pin 10 (XTAL2)  Anslut 16 MHz-kristallen mellan pinnarna, och varsin 22 pF kondensator från varje pinne till GND.
Analog referens Pin 21 (AREF)   Lämna oansluten (eller koppla via 100 nF till GND). Koppla aldrig direkt till VCC om du använder standardinställningar i kod.&lt;/p&gt;
&lt;p&gt;Programmering av kretsen&lt;/p&gt;
&lt;p&gt;För att ladda upp kod till det tomma chippet använder du ett av följande alternativ enligt Phipps Electronics:
• ISP (In-System Programming). Kräver ingen bootloader. Anslut en AVR-programmerare (eller en Arduino Uno som ISP) till Pin 17 (MOSI), Pin 18 (MISO), Pin 19 (SCK), Pin 1 (RESET), samt VCC och GND. [1] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)
• FTDI / USB-till-UART. Kräver att chippet redan har en Arduino-bootloader. Anslut TX och RX från adaptern till Pin 2 (RXD) och Pin 3 (TXD), samt en 100 nF kondensator i serie mellan adapterns DTR-pinne och chipets Pin 1 (RESET) för automatisk återställning vid uppladdning.
Om du berättar mer om ditt projekt kan jag anpassa schemat:
• Spänning och klockfrekvens (t.ex. 5V/16MHz eller batteridrift med 3,3V/8MHz)
• Programmeringsmetod (ISP eller USB-till-seriell/FTDI)
• Kringutrustning som ska styras (sensorer, lysdioder, motorer)&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Atmega328p and pickit5</title>
    <link href="https://jollobajano.com/posts/embedded-baremetal/ATMega328P_and_PicKit5.html"/>
    <id>https://jollobajano.com/posts/embedded-baremetal/ATMega328P_and_PicKit5.html</id>
    <updated>2026-12-03T00:00:00Z</updated>
    <category term="embedded-baremetal" label="Embedded &amp; Bare Metal"/>
    <summary>To program and debug an ATmega328P (28-pin DIP) on a breadboard using the MPLAB PICkit 5, connect the PICkit 5’s 8-pin Single In-Line (SIL) header to the microcontroller&#39;s SPI/ISP pins alongside…</summary>
    <content type="html">&lt;p&gt;To program and debug an ATmega328P (28-pin DIP) on a breadboard using the MPLAB PICkit 5, connect the PICkit 5’s 8-pin Single In-Line (SIL) header to the microcontroller&#39;s SPI/ISP pins alongside basic power and decoupling components. [1] (https://onlinedocs.microchip.com/oxy/GUID-8D61C0B9-A97F-4F4D-99F8-1D7424264C2A-en-US-1/GUID-2E07C091-C3CD-4DE3-9187-80FA1E63E969.html), [2] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Required Components&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;• Microcontroller: ATmega328P-PU (28-pin DIP).
• Programmer: MPLAB PICkit 5 with male-to-male jumper wires (or an 8-pin header).
• Passives:
    • 1× 10 kΩ resistor (for the RESET pull-up).
    • 2× 0.1 µF (100 nF) ceramic capacitors (for power decoupling).
    • (Optional) 1× 16 MHz crystal and 2× 22 pF ceramic capacitors (only needed if you switch from the default 8 MHz internal oscillator to an external clock). [1] (https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard), [2] (https://aherrero.github.io/arduino/iot/2018/09/24/ArduinoToBreadboard.html), [3] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)&lt;/p&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;Breadboard Power &amp;amp; Reset Setup&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Place the ATmega328P across the center ravine of your breadboard and wire the essential support circuitry first:
• Power (5V / 3.3V): Connect Pin 7 (VCC) and Pin 20 (AVCC) to the positive (+) power rail. [1] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)
• Ground: Connect Pin 8 (GND) and Pin 22 (GND) to the negative (-) ground rail.
• Decoupling Capacitors: Place one 0.1 µF capacitor between Pin 7 (VCC) and Pin 8 (GND), and a second 0.1 µF capacitor between Pin 20 (AVCC) and Pin 22 (GND) as close to the chip as possible.
• Reset Pull-Up: Connect the 10 kΩ resistor between Pin 1 (RESET) and the positive (+) power rail. (Note: Do not put a capacitor on the RESET line when using PICkit 5 ISP/debugWIRE, as it interferes with programming pulses). [1] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)&lt;/p&gt;
&lt;ol start=&#34;3&#34;&gt;
&lt;li&gt;PICkit 5 to ATmega328P Wiring (ISP)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;On the MPLAB PICkit 5, Pin 1 is marked by a small triangle/arrow on the front casing. Note that AVR ISP requires using pins 2 through 7 of the 8-pin connector. [1] (https://www.pololu.com/docs/0J67/5.1), [2] (https://onlinedocs.microchip.com/oxy/GUID-8D61C0B9-A97F-4F4D-99F8-1D7424264C2A-en-US-1/GUID-2E07C091-C3CD-4DE3-9187-80FA1E63E969.html)&lt;/p&gt;
&lt;p&gt;PICkit 5 Pin (8-Pin SIL)    PICkit 5 Signal ATmega328P Pin  ATmega328P Function
Pin 1   TVPP / MCLR Not Connected   Leave unconnected for AVR ISP
Pin 2   VTG / VDD   Pin 7 (or + rail)   Target Voltage Sense / Power
Pin 3   GND Pin 8 (or - rail)   Ground
Pin 4   MISO (PGD)  Pin 18  PB4 (MISO)
Pin 5   SCK (PGC)   Pin 19  PB5 (SCK)
Pin 6   RESET (TAUX)    Pin 1   PC6 (RESET)
Pin 7   MOSI (TTDI) Pin 17  PB3 (MOSI)
Pin 8   TTMS    Not Connected   Leave unconnected&lt;/p&gt;
&lt;ol start=&#34;4&#34;&gt;
&lt;li&gt;
&lt;p&gt;MPLAB X IDE Configuration&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a Project: Open MPLAB X IDE, select Standalone Project, choose ATmega328P as the device, and select PICkit 5 as your hardware tool. [1] (https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/Brochures/MPLAB-PICkit-5-In-Circuit-Debugger-Quick-Start-Guide-50003478.pdf), [2] (https://www.youtube.com/watch?v=_vOkFvMzuyg)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;Powering the Chip: By default, PICkit 5 expects the breadboard to have its own power supply. If you want the PICkit 5 to power the ATmega328P directly (up to 150 mA):
    • Open Project Properties -&amp;gt; PICkit 5.
    • Change Option categories to Power.
    • Check Power target circuit from PICkit 5 and set the voltage level (typically 5.0V for a stock ATmega328P). [1] (https://www.youtube.com/watch?v=_vOkFvMzuyg)&lt;/li&gt;
&lt;li&gt;Programming &amp;amp; Debugging:
    • Click Make and Program Device to flash via SPI (ISP).
    • If you click Debug Main Project, MPLAB X will prompt you to enable the DWEN (debugWIRE) fuse, which allows single-wire debugging through Pin 1 (RESET). (Remember to use the &#34;Disable debugWIRE&#34; option in MPLAB before disconnecting if you want to return to standard ISP programming). [1] (https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/UserGuides/MPLAB-PICkit-5-In-Circuit-Debugger-Users-Guide-50003525.pdf), [2] (https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/Brochures/MPLAB-PICkit-5-In-Circuit-Debugger-Quick-Start-Guide-50003478.pdf)
Let me know if you need help with:
• Setting up external 16 MHz crystal fuse bits
• Configuring debugWIRE vs. ISP in MPLAB X
• Using Arduino sketches with the PICkit 5&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry>
  <entry>
    <title>Installing Arch Linux on a Raspberry Pi 3 B</title>
    <link href="https://jollobajano.com/posts/programming/2026-03-21-Installing-Arch-Linux-on-a-Raspberry-Pi-3B.html"/>
    <id>https://jollobajano.com/posts/programming/2026-03-21-Installing-Arch-Linux-on-a-Raspberry-Pi-3B.html</id>
    <updated>2026-03-21T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>Create partition table, boot partition and root partition.</summary>
    <content type="html">&lt;pre&gt;&lt;code&gt;$ dd if=/dev/zero of=arch.img bs=1024 count=14680000


$ fdisk arch.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create partition table, boot partition and root partition.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo losetup --partscan --show --find arch.img 
/dev/loop3

$ ls /dev/loop3
loop3    loop3p1  loop3p2


$ sudo mkfs.vfat /dev/loop3p1
mkfs.fat 4.2 (2021-01-31)
ubuntu:bounce $ sudo mkfs.ext4 /dev/loop3p2
mke2fs 1.47.2 (1-Jan-2025)
Discarding device blocks: done                            
Creating filesystem with 3644144 4k blocks and 912128 inodes
Filesystem UUID: 0833ae91-b016-42ea-99f8-af61038498c6
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done



$ mkdir root boot
$ sudo mount /dev/loop3p1 boot
$ sudo mount /dev/loop3p2 root

$ wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz
$ cd root
$ sudo tar xvfz ../ArchLinuxARM-rpi-armv7-latest.tar.gz
$ cd ..
$ mv root/boot/* boot

$ sudo umount root boot

$ losetup -d /dev/loop3

$ rmdir root boot
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Transfer arch,img to a 16GB SD card.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>The birthday problem</title>
    <link href="https://jollobajano.com/posts/mathematics/2019-08-08-Birthday-problem.html"/>
    <id>https://jollobajano.com/posts/mathematics/2019-08-08-Birthday-problem.html</id>
    <updated>2019-08-08T00:00:00Z</updated>
    <category term="mathematics" label="Mathematics"/>
    <category term="mathematics"/>
    <category term="probability"/>
    <summary>How many people do you need in a room for there to be an even chance that two of them share a birthday?</summary>
    <content type="html">&lt;p&gt;How many people do you need in a room for there to be an even chance
that two of them share a birthday?&lt;/p&gt;
&lt;p&gt;Most people guess somewhere around 180 – half of 365 seems reasonable.
The real answer is &lt;strong&gt;23&lt;/strong&gt;. With 70 people the chance is 99.9 %.&lt;/p&gt;
&lt;p&gt;This is usually called the &lt;em&gt;birthday paradox&lt;/em&gt;, but it isn&#39;t really a
paradox. Nothing contradicts itself; the answer just baffles our
intuition. It makes a great party trick, and if you can explain why it
works, someone may even take you for a mathematician.&lt;/p&gt;
&lt;h2&gt;Why our intuition fails&lt;/h2&gt;
&lt;p&gt;When we hear the question, we tend to think about &lt;em&gt;ourselves&lt;/em&gt;: what is
the chance that someone in the room has &lt;em&gt;my&lt;/em&gt; birthday? That chance
really is small. With 22 other people it is only about 6 %.&lt;/p&gt;
&lt;p&gt;But the question is about &lt;em&gt;any&lt;/em&gt; two people. In a room of 23 there are&lt;/p&gt;
&lt;p&gt;\[\binom{23}{2} = \frac{23 \cdot 22}{2} = 253\]&lt;/p&gt;
&lt;p&gt;pairs of people, and every one of those pairs is a chance for a match.
Each pair matches with a probability of only \(1/365\), but 253 small
chances add up quickly.&lt;/p&gt;
&lt;h2&gt;Doing the maths&lt;/h2&gt;
&lt;p&gt;It is easier to compute the probability that &lt;em&gt;no&lt;/em&gt; two people share a
birthday, and subtract that from one. Assume 365 equally likely
birthdays (ignore 29 February) and add people one at a time:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the first person can have any birthday: \(365/365\),&lt;/li&gt;
&lt;li&gt;the second must avoid the first: \(364/365\),&lt;/li&gt;
&lt;li&gt;the third must avoid both: \(363/365\),&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;and so on. For \(n\) people, the probability that all birthdays differ is&lt;/p&gt;
&lt;p&gt;\[\bar{P}(n) = \frac{365}{365} \cdot \frac{364}{365} \cdots \frac{365 - n + 1}{365}
           = \prod_{k=0}^{n-1} \left( 1 - \frac{k}{365} \right),\]&lt;/p&gt;
&lt;p&gt;and the probability of at least one shared birthday is&lt;/p&gt;
&lt;p&gt;\[P(n) = 1 - \bar{P}(n).\]&lt;/p&gt;
&lt;p&gt;Putting in a few values:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align: right;&#34;&gt;People \(n\)&lt;/th&gt;
&lt;th style=&#34;text-align: right;&#34;&gt;Chance of a shared birthday&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;10&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;11.7 %&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;20&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;41.1 %&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;&lt;strong&gt;23&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;&lt;strong&gt;50.7 %&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;30&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;70.6 %&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;40&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;89.1 %&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;50&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;97.0 %&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;57&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;99.0 %&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;&lt;strong&gt;70&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&#34;text-align: right;&#34;&gt;&lt;strong&gt;99.9 %&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;A handy approximation&lt;/h2&gt;
&lt;p&gt;Since \(1 - x \approx e^{-x}\) for small \(x\), the product turns into a sum
in the exponent:&lt;/p&gt;
&lt;p&gt;\[P(n) \approx 1 - e^{-n(n-1)/(2 \cdot 365)}.\]&lt;/p&gt;
&lt;p&gt;Setting this to one half and solving gives&lt;/p&gt;
&lt;p&gt;\[n \approx \sqrt{2 \cdot 365 \cdot \ln 2} \approx 22.5,\]&lt;/p&gt;
&lt;p&gt;so 23 people. More generally, with \(d\) equally likely &#34;days&#34;, a
coincidence becomes likely after only about \(1.2\sqrt{d}\) tries. That
square root is why the effect shows up far beyond birthdays: in hash
tables, in lottery numbers and in the so-called &lt;em&gt;birthday attack&lt;/em&gt; on
cryptographic hash functions.&lt;/p&gt;
&lt;h2&gt;And &lt;em&gt;my&lt;/em&gt; birthday?&lt;/h2&gt;
&lt;p&gt;The intuitive question has an answer too. The chance that none of \(n\)
other people shares your birthday is&lt;/p&gt;
&lt;p&gt;\[\left( \frac{364}{365} \right)^n,\]&lt;/p&gt;
&lt;p&gt;and for that to drop below one half you need \(n = 253\) people – exactly
as many as the pairs in a room of 23.&lt;/p&gt;
&lt;h2&gt;Real birthdays&lt;/h2&gt;
&lt;p&gt;Real birthdays aren&#39;t spread evenly over the year; some weeks see
noticeably more births than others. That only makes a match &lt;em&gt;more&lt;/em&gt;
likely, so 23 is, if anything, a slight overestimate.&lt;/p&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Borja, M. C. and Haigh, J. (2007). &lt;a href=&#34;https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2007.00246.x&#34;&gt;&#34;The birthday problem&#34;&lt;/a&gt;.
   &lt;em&gt;Significance&lt;/em&gt;, 4:124–127. doi:10.1111/j.1740-9713.2007.00246.x&lt;/li&gt;
&lt;li&gt;Azad, K. &lt;a href=&#34;https://betterexplained.com/articles/understanding-the-birthday-paradox/&#34;&gt;&#34;Understanding the Birthday Paradox&#34;&lt;/a&gt;. &lt;em&gt;Better
   Explained&lt;/em&gt;, retrieved 2019-08-08.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.scientificamerican.com/article/bring-science-home-probability-birthday-paradox/&#34;&gt;&#34;Probability and the birthday paradox&#34;&lt;/a&gt;. &lt;em&gt;Scientific American&lt;/em&gt;,
   Bring Science Home.&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry>
  <entry>
    <title>Where do I put the beans.xml file(s)</title>
    <link href="https://jollobajano.com/posts/programming/2019-01-02-Where-do-I-put-the-beans.xml-file.html"/>
    <id>https://jollobajano.com/posts/programming/2019-01-02-Where-do-I-put-the-beans.xml-file.html</id>
    <updated>2019-01-02T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>This is a post regarding the GitHub project Maven Multi Jar Webapp with Embedded Interceptor about how to enable interceptors in CDI and a Maven multi module project.</summary>
    <content type="html">&lt;p&gt;This is a post regarding the GitHub project &lt;a href=&#34;https://github.com/matsnyberg/maven-multi-jar-webapp-with-embedded-interceptor&#34;&gt;Maven Multi Jar Webapp
with Embedded Interceptor&lt;/a&gt; about how to enable interceptors in CDI
and a Maven multi module project.&lt;/p&gt;
&lt;p&gt;This is a &lt;em&gt;minimal working example&lt;/em&gt;, a MWE, showing how to enable
interceptors in a multi jar JavaEE CDI application.&lt;/p&gt;
&lt;p&gt;What gave me a big aha! moment was the following tip out of &lt;em&gt;JBoss
Weld CDI for Java Platform Learn CDI concepts and develop modern web
applications using JBoss Weld&lt;/em&gt; by Ken Finnigan:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Activation of an interceptor within beans.xml will activate it for
all beans within the same archive only.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is the root of many &#34;why woun&#39;t my interceptor work?&#34; questions
on StackOverflow.&lt;/p&gt;
&lt;h2&gt;This project layout&lt;/h2&gt;
&lt;p&gt;This project consists of a root project POM (my standard issue POM for
J2EE projects. It&#39;s a bit heavy so don&#39;t spend any time on it.), and
three child projects/modules: &lt;em&gt;application&lt;/em&gt;, &lt;em&gt;beans&lt;/em&gt; and &lt;em&gt;intercept&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;intercept&lt;/em&gt; contains an interceptor binding, &lt;code&gt;@ResourceModel&lt;/code&gt;, and
it&#39;s interceptor.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@InterceptorBinding
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface ResourceModel {

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@Interceptor
@ResourceModel
public class ResourceModelInterceptor {
    private static final Logger log = LoggerFactory.getLogger(ResourceModelInterceptor.class);

    @AroundInvoke
    public Object aroundMethod(InvocationContext ctx) throws Exception {
        log.info(&#34;Before&#34;);
        return ctx.proceed();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;application&lt;/em&gt; contains the JAX-RS application (&#34;api&#34;) and one REST
endpoint (&#34;test&#34;). The endpoint is marked by the &lt;code&gt;@ResourceModel&lt;/code&gt;
annotation.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@ApplicationPath(&#34;/api&#34;)
public class TestApplication extends Application {}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@ResourceModel
@Path(&#34;test&#34;)
public class TestEndpoint {

    private String resource = &#34;Hello World!&#34;;

    @GET
    @Produces(&#34;test/plain&#34;)
    public Response simpleGet() {
        return Response.ok(resource)
                .build();

    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;beans&lt;/em&gt; lastly, contains another endpoint (&#34;beans&#34;). This is also
annotated with the &lt;code&gt;@ResourceModel&lt;/code&gt; interceptor binding.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@ResourceModel
@Path(&#34;beans&#34;)
public class BeansResource {

    private String resource = &#34;Hello Beans!&#34;;

    @GET
    @Produces(&#34;test/plain&#34;)
    public Response simpleGet() {
        return Response.ok(resource)
                .build();

    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is a &lt;code&gt;beans.xml&lt;/code&gt; template file enabling the
&lt;code&gt;jollobajano.test.ResourceModelInterceptor&lt;/code&gt; from the &lt;em&gt;intercept&lt;/em&gt;
module. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;beans
    xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34;
    xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34;
    xsi:schemaLocation=&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd&#34;&amp;gt;
    &amp;lt;interceptors&amp;gt;
    &amp;lt;class&amp;gt;jollobajano.test.ResourceModelInterceptor&amp;lt;/class&amp;gt;
    &amp;lt;/interceptors&amp;gt;
&amp;lt;/beans&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This template can be found in the root of this project.&lt;/p&gt;
&lt;h2&gt;Where to put the &lt;code&gt;beans.xml&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Taking the hint from the tip from the book.... we &lt;em&gt;need to enable the
interceptor in all the modules where we want it to intercept&lt;/em&gt;. This
means that for &lt;em&gt;beans&lt;/em&gt; we copy the file into the
&lt;code&gt;src/main/resources/META-INF&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;Since &lt;em&gt;application&lt;/em&gt; is a &lt;code&gt;war&lt;/code&gt; type module, we copy the interceptor
enabeling &lt;code&gt;beans.xml&lt;/code&gt; into the &lt;code&gt;src/main/webapp/WEB-INF&lt;/code&gt; of that
module.&lt;/p&gt;
&lt;p&gt;I first experimented with presence and absence of the &lt;code&gt;beans.xml&lt;/code&gt; file
in the &lt;em&gt;application&lt;/em&gt; and &lt;em&gt;beans&lt;/em&gt; modules and was able to control
whether the interceptor would work in each particular module that way.&lt;/p&gt;
&lt;p&gt;A reoccuring question on StackOverflow and other forums is &#34;where do I
put the &lt;code&gt;beans.xml&lt;/code&gt; file?&#34;. Experimenting with this project I
concluded that&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;in a JAR archive, we put the &lt;code&gt;beans.xml&lt;/code&gt; file in a &lt;code&gt;META-INF&lt;/code&gt;
   directory in the root of the archive,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;in a WAR archive the &lt;code&gt;beans.xml&lt;/code&gt; file goes into the &lt;code&gt;WEB-INF&lt;/code&gt;
   folder.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The way I see it, enabeling an interceptor via the &lt;code&gt;beans.xml&lt;/code&gt; file
tells the CDI framework, e.g. Weld, to &lt;em&gt;enable the interceptor for the
archive that contains the enabeling &lt;code&gt;beans.xml&lt;/code&gt;&lt;/em&gt;.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Homemade drain cleaner</title>
    <link href="https://jollobajano.com/posts/chemistry/2018-11-04-Drain-cleaner.html"/>
    <id>https://jollobajano.com/posts/chemistry/2018-11-04-Drain-cleaner.html</id>
    <updated>2018-11-04T00:00:00Z</updated>
    <category term="chemistry" label="Chemistry"/>
    <summary>!! In Progress !!</summary>
    <content type="html">&lt;p&gt;!! In Progress !!&lt;/p&gt;
&lt;p&gt;If you have a slow drainage in the kitchen or bathroom and it is due
to a clogg in a siphon, then you should absolutely try this house
wife&#39;s recipe:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Pour some baking soda or hydrocarbonate into the drainage.&lt;/li&gt;
&lt;li&gt;(Optional) Pour some table salt into the drainage.&lt;/li&gt;
&lt;li&gt;Pour some vinnegar or other source of acetic acid into the
    drainage.&lt;/li&gt;
&lt;li&gt;Wait for five to ten minutes to let the reaction work on the
    clog.&lt;/li&gt;
&lt;li&gt;Now flush the frain pipe (on the inside) with a couple of liters
    of boiling water. I actually just opened up the hot water tap on
    it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This will cause a reaction between the baking soda and the acetic acid
that sound dramatic. The fizzling and &lt;em&gt;boiling sound&lt;/em&gt; is, however,
just the carbon dioxide, \(\ce{CO2}\), being released. It doesn&#39;t damage
anything.&lt;/p&gt;
&lt;p&gt;The reaction is even &lt;em&gt;endothermic&lt;/em&gt; so it rather cooles the system, or
immediate environment, rather than heats it up.&lt;/p&gt;
&lt;h2&gt;What happens?&lt;/h2&gt;
&lt;p&gt;The reaction from mixing baking powder (\(\ce{NaHCO3}\)) and acetic
acid (\(\ce{CH3COOH}\)) proceeds in two steps. In the first step
baking powder looses the sodium for a hydrogen ion and the acid
picks up the sodium ion.&lt;/p&gt;
&lt;p&gt;\[\ce{ NaHCO3 (s) + CH3COOH (l) -&amp;gt; CH3COONa + H2CO3(aq)  }\]&lt;/p&gt;
&lt;p&gt;The resulting products are sodiumacetate and carbon acid. In the next
step&lt;/p&gt;
&lt;p&gt;\[\ce{ H2CO3(aq) → CO2(g) + H2O(l) }\]&lt;/p&gt;
&lt;p&gt;and together we have&lt;/p&gt;
&lt;p&gt;\[\ce{ CH3COOH(aq) + NaCO3(s) → CH3COONa(aq) + CO2(g) + H2O(l) }\]&lt;/p&gt;
&lt;h2&gt;Why does this work?&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;The release of gas within the clog may loosen it up.&lt;/li&gt;
&lt;li&gt;The acidity of the acetic acid as well as the carbon dioxide also
    help dissolve the clog.&lt;/li&gt;
&lt;li&gt;Rinsing with hot water gives adduction/convection, i.e. it drags
    solids with it as it runs through the pipes. The temperature of
    the water melts fatty compounds in the clog which destabilizes
    it.&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry>
  <entry>
    <title>Angular2 factory provider pattern</title>
    <link href="https://jollobajano.com/posts/programming/2018-04-09-Angular2-factory.html"/>
    <id>https://jollobajano.com/posts/programming/2018-04-09-Angular2-factory.html</id>
    <updated>2018-04-09T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>This is just a note of the provider pattern for services in Anglar2 which has been somewhat elusive to me, moving from Angular1 to Anguar2 and TypeScript. Trolling the internet I&#39;ve found that the…</summary>
    <content type="html">&lt;p&gt;This is just a note of the &lt;code&gt;provider&lt;/code&gt; pattern for services in Anglar2
which has been somewhat elusive to me, moving from Angular1 to Anguar2
and TypeScript. Trolling the internet I&#39;ve found that the following
works:&lt;/p&gt;
&lt;p&gt;Creating a &#34;logger service&#34; by &lt;code&gt;ng generate service service/logger&lt;/code&gt;
creates a service scaffold in &lt;code&gt;service/logger.service.ts&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { Injectable } from &#39;@angular/core&#39;;

@Injectable()
export class LoggerService {

    constructor() {
    console.log(&#39;LoggerService constructor&#39;);
    }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A provider is the just a &#34;plain old Javascript object&#34; constituting a
providr entry of a &lt;code&gt;@NgModule&lt;/code&gt; which we export from
&lt;code&gt;service/logger.service.provider.ts&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { LoggerService } from &#39;./logger.service&#39;;

let loggerServiceFactory = () =&amp;gt; {
    console.log(&#39;loggerServiceFactory()&#39;);
    return new LoggerService();
};

export let loggerServiceProvider =
    { provide: LoggerService,
      useFactory: loggerServiceFactory,
      deps: []
    };
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we declare the provider in a &lt;code&gt;@NgModule&lt;/code&gt; in the provider clause.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { BrowserModule } from &#39;@angular/platform-browser&#39;;
import { NgModule } from &#39;@angular/core&#39;;

import { AppRoutingModule } from &#39;./app-routing.module&#39;;

import { AppComponent } from &#39;./app.component&#39;;
import { DemoComponentComponent } from &#39;./demo-component/demo-component.component&#39;;
import { LoggerService } from &#39;./service/logger.service&#39;;
import { loggerServiceProvider } from &#39;./service/logger.service.provider&#39;;
import { NavComponent } from &#39;./nav/nav.component&#39;;


@NgModule({
  declarations: [
    AppComponent,
    DemoComponentComponent,
    NavComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [loggerServiceProvider],
  bootstrap: [AppComponent]
})
export class AppModule { }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This lets me inject &lt;code&gt;LoggerService&lt;/code&gt;s into components throughout the
app in the familliar manner&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { Component, OnInit } from &#39;@angular/core&#39;;
import { LoggerService } from &#39;../service/logger.service&#39;;

@Component({
    selector: &#39;app-demo-component&#39;,
    templateUrl: &#39;./demo-component.component.html&#39;,
    styleUrls: [&#39;./demo-component.component.scss&#39;]
})
export class DemoComponentComponent implements OnInit {

    log: LoggerService;

    constructor(log: LoggerService) {
    this.log = log;
    }

    ngOnInit() { }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the Javascript console of a browser I can see that the creation of
the &lt;code&gt;LoggerService&lt;/code&gt; invokes my &lt;code&gt;loggerServiceProvider&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I then changed the &lt;code&gt;logger.service.provider.ts&lt;/code&gt; into &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { LoggerService } from &#39;./logger.service&#39;;

let name: string = &#34;None&#34;;

let loggerServiceFactory = () =&amp;gt; {
    console.log(&#39;loggerServiceFactory()&#39;);
    return new LoggerService(this.name);
};

export let loggerServiceProvider = (name: String) =&amp;gt; {
    this.name = name;    
    return { provide: LoggerService,
         useFactory: loggerServiceFactory,
         deps: []
       };
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which aloows for a parameterized service, the &lt;code&gt;loggerServiceProvider&lt;/code&gt;
becomes what one in the olden days would call &lt;code&gt;$get&lt;/code&gt;. This can be used
in the &lt;code&gt;app.module.ts&lt;/code&gt; to initiate services.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; import { BrowserModule } from &#39;@angular/platform-browser&#39;;
 import { NgModule } from &#39;@angular/core&#39;;

 import { AppRoutingModule } from &#39;./app-routing.module&#39;;

 import { AppComponent } from &#39;./app.component&#39;;
 import { DemoComponentComponent } from &#39;./demo-component/demo-component.component&#39;;
 import { LoggerService } from &#39;./service/logger.service&#39;;
 import { loggerServiceProvider } from &#39;./service/logger.service.provider&#39;;
 import { NavComponent } from &#39;./nav/nav.component&#39;;


 @NgModule({
   declarations: [
     AppComponent,
     DemoComponentComponent,
     NavComponent
   ],
   imports: [
     BrowserModule,
     AppRoutingModule
   ],
     providers: [
       loggerServiceProvider(&#39;Mats&#39;)
     ],
   bootstrap: [AppComponent]
 })
 export class AppModule {}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The clause&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;providers: [loggerServiceProvider(&#39;Mats&#39;)]`
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;should  be more something like&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;providers: [rootResource(&#39;/api&#39;)]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in a serious application.&lt;/p&gt;
&lt;p&gt;The two examples shows the patterns formerly known as the
&lt;code&gt;.provider()&lt;/code&gt; pattern and the &lt;code&gt;.factory()&lt;/code&gt; pattern respectively.&lt;/p&gt;
&lt;p&gt;Nifty.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Ruby — classes extending and including modules</title>
    <link href="https://jollobajano.com/posts/programming/2017-05-20-classes-extending-and-including-modules.html"/>
    <id>https://jollobajano.com/posts/programming/2017-05-20-classes-extending-and-including-modules.html</id>
    <updated>2017-05-20T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>In Ruby, modules can be used to encapsulate reusable code that can be included in classes, either as instance methods or class methods. The example below show the difference between the include and…</summary>
    <content type="html">&lt;p&gt;In Ruby, modules can be used to encapsulate reusable code that can be
included in classes, either as instance methods or class methods. The
example below show the difference between the &lt;code&gt;include&lt;/code&gt; and &lt;code&gt;extend&lt;/code&gt;
mechanisms. &lt;code&gt;include&lt;/code&gt; mixes in the module methods as instance
methods. The &lt;code&gt;extend&lt;/code&gt; mechanism imports the module methods as class
methods.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;module ReusableModule
  def module_method
    puts &#34;Module Method: Hi there!&#34;
  end
end

class ClassThatIncludes
  include ReusableModule
end
class ClassThatExtends
  extend ReusableModule
end

puts &#34;Include&#34;
ClassThatIncludes.new.module_method       # &#34;Module Method: Hi there!&#34;
puts &#34;Extend&#34;
ClassThatExtends.module_method            # &#34;Module Method: Hi there!&#34;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This produces the output&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Include
Module Method: Hi there!
Extend
Module Method: Hi there!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So when a class &lt;code&gt;extend&lt;/code&gt; a module, the module methods are added to the
class as &lt;em&gt;class methods&lt;/em&gt; (corresponding to &lt;code&gt;static&lt;/code&gt; methods in
Java). When a Ruby class &lt;code&gt;include&lt;/code&gt; a module, the module methods are
added to the class as &lt;em&gt;instance methods&lt;/em&gt;.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Abilene paradox</title>
    <link href="https://jollobajano.com/posts/social/2016-11-16-Abilene-paradox.html"/>
    <id>https://jollobajano.com/posts/social/2016-11-16-Abilene-paradox.html</id>
    <updated>2016-11-16T00:00:00Z</updated>
    <category term="social" label="Social"/>
    <category term="psychology"/>
    <category term="sociology"/>
    <category term="feature"/>
    <summary>The notion of an Abilene paradox describes a situation in which a group of people comes to a mutual decision that is contrary to what some or all of the group members prefer or believe is best.</summary>
    <content type="html">&lt;p&gt;The notion of an &lt;a href=&#34;https://en.wikipedia.org/wiki/Abilene_paradox&#34;&gt;&lt;em&gt;Abilene paradox&lt;/em&gt;&lt;/a&gt; describes a situation in which a
group of people comes to a mutual decision that is contrary to what
some or all of the group members prefer or believe is best.&lt;/p&gt;
&lt;p&gt;The situation comes from a lack or absence of communication within the
group and beliefs among the members that their opinions are contrary
to the group&#39;s. Members do not wish to &lt;em&gt;rock the boat&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The Abilene paradox was presented and described 1974 (Harvey, 1974) as
&lt;em&gt;a group&#39;s inability to agree&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;In this article he illustrates the phenomenon by telling a family
anecdote where he, his wife and his parent in law decides to take a
trip on an excruciatingly hot Texas afternoon in spite of all of them
rather have stayed at home. The decision comes from a shared belief
that the other family members want to go and no one want to oppose the
perceived conformity of the group.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The July afternoon in Coleman, Texas (popula- tion 5,607) was
particularly hot—104 degrees as measured by the Walgreen&#39;s Rexall
Ex-Lax temperature gauge. In addition, the wind was blowing
fine-grained West Texas topsoil through the house. But the afternoon
was still tolerable — evern potentially enjoyable. There was a fan
going on the back porch; there was cold lemonade; and finally, there
was enter- tainment. Dominoes. Perfect for the condi- tions. The
game required little more physical exertion than an occasional
mumbled com- ment. &#34;Shuffle em,&#34; and an unhurried movement of the
arm to place the spots in the ap- propriate perspective on the
table. All in all,it had the makings of an agreeable Sunday
afternoon in Coleman — that is, it was until my father-in-law
suddenly said, &#34;Let&#39;s gel in the car and go to Abilene and have
dinner at the cafeteria.&#34;&lt;/p&gt;
&lt;p&gt;I thought, &#34;What, go to Abilene? Fifty-three miles? In this dust
storm and heat? And in an unairconditioned 1958 Buick?&#34; But my wife
chimed in with, &#34;Sounds like a great idea. I&#39;d like to go. How about
you, Jerry?&#34; Since my own preferences were obviously out of step
with the rest I re- plied, &#34;Sounds good to me,&#34; and added, &#34;I just
hope your mother wants to go.&#34; &lt;/p&gt;
&lt;p&gt;Some four hours and 106 miles later we returned to Coleman, hot and
exhausted. We sat in front of the fan for a long time in
silence. Then, both to be sociable and to break the silence, I said,
&#34;It was a great trip, wasn&#39;t it?&#34; &lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;My wife looked shocked. &#34;Don&#39;t call me a culprit. You and Daddy and
Mama were the ones who wanted to go. I just went along to be
sociable and to keep you happy. I would have had to be crazy to want
to go out in heat like that.&#34; &lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;we all sat back in silence. Here we were, four reasonably sensible
people who, of our own volition, had just taken a 106-mile trip
across a godforsaken desert in a furnace-like temper- ature through
a cloud-like dust storm to eat unpalatable food at a
hole-in-the-wall cafete- ria in Abilene, when none of us had really
wanted to go. In fact, to be more accurate, we&#39;d done just the
opposite of what we wanted to do. The whole situation simply didn&#39;t
make sense. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;em&gt;The Watergate break-in&lt;/em&gt; at the Democratic party&#39;s national headquarter
by the Nixon administration in the 1970s is given by Harvey as an
example of an Abilene paradox. Indicted members of the administration
expressed that they did not like the plans but wouldn&#39;t go against the
perceived certainty of the other group members.&lt;/p&gt;
&lt;p&gt;People involved in an Abilene paradox generally do not like the
decision and have more negative feelings about the outcome. This
separates the Abilene paradox from &lt;a href=&#34;https://en.wikipedia.org/wiki/Groupthink&#34;&gt;&lt;em&gt;groupthink&lt;/em&gt;&lt;/a&gt;. in which loyalty
to the group prevent members from expressing descent or opposing
opinions.&lt;/p&gt;
&lt;h2&gt;The Comic-Con Conundrum&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;The Comic-Con Conundrum&lt;/em&gt; is the seventeenth episode of the tenth
season of the American sitcom The Big Bang Theory. In the episode,
Leonard and Penny plans to go to &lt;em&gt;Comic Con&lt;/em&gt; together. It turns out
that neither Leonard nor Penny are particularly excited about the
upcomming trip. Leonard have invited Penny as a gesture of affection,
to show her she matters and is not exclude or left out. Penny, in the
other hand, have agreed as a similar gesture towards Leonard. She
confesses to Amy: &lt;em&gt;I can put up with anything for a weekend&lt;/em&gt;. Leonard
and Penny are both guilty parties in arranging for something both of
them thinjs is a bad idea as both believes this is what the other
party wants. It is an obvious example of the Abilene Paradox.&lt;/p&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Harvey, J. B. (1974). &lt;a href=&#34;http://homepages.se.edu/cvonbergen/files/2013/01/The-Abilene-Paradox_The-Management-of-Agreement.htm_.pdf&#34;&gt;&#34;The Abilene paradox: the management of agreement&#34;&lt;/a&gt;. &lt;em&gt;Organizational Dynamics&lt;/em&gt;. 3: 63–80&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry>
  <entry>
    <title>An illustrative $q service unit test case</title>
    <link href="https://jollobajano.com/posts/programming/2016-02-07-q-testing.html"/>
    <id>https://jollobajano.com/posts/programming/2016-02-07-q-testing.html</id>
    <updated>2016-02-07T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>This test case shows different ways to use $q.defer() and resolve().</summary>
    <content type="html">&lt;p&gt;This test case shows different ways to use &lt;code&gt;$q.defer()&lt;/code&gt; and
&lt;code&gt;resolve()&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    &#39;use strict&#39;;
    describe(&#39;how to test with promises&#39;, function () {
        var deferred, $rootScope;

        beforeEach(function () {
            inject(function ($q, _$rootScope_) {
                $rootScope = _$rootScope_;
                deferred = $q.defer();
            });
        });

        it(&#39;does a thing one way&#39;, function () {
            deferred.promise.then(function (value) {
                expect(value).toBe(10);
            });
            deferred.resolve(10);
            $rootScope.$digest();
         });

         it(&#39;does a thing another way&#39;, function () {
             var handler = jasmine.createSpy(&#39;success&#39;);
             deferred.promise.then(handler);
             deferred.resolve(4);
             $rootScope.$digest();
             expect(handler).toHaveBeenCalledWith(4);
         });

        it(&#39;does a thing one way&#39;, function() {
            var value;
            deferred.promise.then(function(_value_) {
                value = _value_;
            });
            deferred.resolve(10);
            expect(value).not.toBe(10); // not yet 10 because 
                                        // $digest hasn&#39;t run
            $rootScope.$digest();
            expect(value).toBe(10); // 10 because $digest 
                                    // already ran
        });
     });
&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>Modify the Maven build command for Git commit triggered builds on Open Shift</title>
    <link href="https://jollobajano.com/posts/programming/2016-02-06-custom-openshift-maven-command.html"/>
    <id>https://jollobajano.com/posts/programming/2016-02-06-custom-openshift-maven-command.html</id>
    <updated>2016-02-06T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>The Open Shift standard Maven build command is mvn clean package -Popenshift -DskipTests.</summary>
    <content type="html">&lt;p&gt;The Open Shift standard Maven build command is 
&lt;code&gt;mvn clean package -Popenshift -DskipTests&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;Developing my &lt;em&gt;tennis club admin tool&lt;/em&gt; (Smash), I used Arquillian for
the integration testing. Following &lt;em&gt;best practices&lt;/em&gt; principle that
says that yoou should be able to clone a project to your hard drive,
issue &lt;code&gt;mvn clean install&lt;/code&gt; and it should work, the default Arquillian
profile is to run my Wildfly instances managed. This means that Maven
downloads a Wildfly distribution for every module of the
project.&lt;/p&gt;
&lt;p&gt;Building Smash straight off didnät work since the project consists of
twenty modules and the download of Wildfly dists depleted the disc
space during build.&lt;/p&gt;
&lt;p&gt;On my home site I build the entire deployment issuing 
&lt;code&gt;mvn clean install -DskipTests -Parq-wildfly-remote&lt;/code&gt;. This, of course,
skips testing. Arquillian still downloads the Wildfly dist unless I
activate the &lt;code&gt;arq-wildfly-remote&lt;/code&gt; profile, and I needed to do this on OPen
Shift as well.&lt;/p&gt;
&lt;p&gt;The sollutio to modify the Maven build command is found in the
&lt;code&gt;.openshift&lt;/code&gt; directory of the Git repository. Inside there is the file
&lt;code&gt;.openshift/action_hooks/pre_build_wildfly&lt;/code&gt;. This contains the
&lt;code&gt;MAVEN_ARGS&lt;/code&gt; environment variable that sets the goals and options of
triggered builds.&lt;/p&gt;
&lt;p&gt;I changed the file, accordingly to&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
export MAVEN_ARGS=&amp;quot;clean package -Popenshift,arq-wildfly-remote -DskipTests&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which solved my problem.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Git -- How to squash all commits on branch</title>
    <link href="https://jollobajano.com/posts/programming/2015-12-28-Git-How-to-squash-all-commits-on-branch.html"/>
    <id>https://jollobajano.com/posts/programming/2015-12-28-Git-How-to-squash-all-commits-on-branch.html</id>
    <updated>2015-12-28T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>Ripped from Git: How to squash all commits on branch.</summary>
    <content type="html">&lt;p&gt;Ripped from &lt;a href=&#34;http://stackoverflow.com/questions/25356810/git-how-to-squash-all-commits-on-branch&#34;&gt;Git: How to squash all commits on branch&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Question&lt;/h2&gt;
&lt;p&gt;I make new branch from master with:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git checkout -b testbranch&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I make 20 commits into it.&lt;/p&gt;
&lt;p&gt;Now I want to squash those 20 commits. I do that with:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git rebase -i HEAD~20&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;What about if I don&#39;t know how many commits?&lt;/p&gt;
&lt;h2&gt;Answer&lt;/h2&gt;
&lt;p&gt;Another way to squash all your commits is to reset the index to master:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; git checkout yourBranch
 git reset $(git merge-base master yourBranch)
 git add -A
 git commit -m &amp;quot;one commit on yourBranch&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This isn&#39;t perfect as it implies you know from which branch
&#34;yourBranch&#34; is coming from.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Enable SSL on Wildfly 8.2.1</title>
    <link href="https://jollobajano.com/posts/programming/2015-12-23-enable-ssl-on-wildfly-8.2.1.html"/>
    <id>https://jollobajano.com/posts/programming/2015-12-23-enable-ssl-on-wildfly-8.2.1.html</id>
    <updated>2015-12-23T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>Knicked from &#34;how to configure ssl in wildfly 8.2.0 server?&#34;.</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Knicked from &#34;&lt;a href=&#34;http://stackoverflow.com/questions/29138478/how-to-configure-ssl-in-wildfly-8-2-0-server&#34;&gt;how to configure ssl in wildfly 8.2.0 server?&lt;/a&gt;&#34;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;This will be short and sweet.&lt;/p&gt;
&lt;h3&gt;Step1: Creating keystore&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;$ cd $WILDFLY_HOME/standalone/configuration
$ keytool -genkey -alias localhost -keyalg RSA -keystore keystore.jks -keysize 4096
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Step2: Editing configuration/standalone.xml&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&#34;language-xml&#34;&gt;&amp;lt;security-realms&amp;gt;
  **&amp;lt;security-realm name=&amp;quot;SslRealm&amp;quot;&amp;gt;
    &amp;lt;server-identities&amp;gt;
      &amp;lt;ssl&amp;gt; 
        &amp;lt;keystore path=&amp;quot;keystore.jks&amp;quot;
          relative-to=&amp;quot;jboss.server.config.dir&amp;quot;
          keystore-password=&amp;quot;changeme&amp;quot;/&amp;gt;
      &amp;lt;/ssl&amp;gt;
    &amp;lt;/server-identities&amp;gt;
  &amp;lt;/security-realm&amp;gt;**
&amp;lt;/security-realms&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Step3: Adding listener for https by editing standalone.xml&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&#34;language-xml&#34;&gt;&amp;lt;subsystem xmlns=&amp;quot;urn:jboss:domain:undertow:1.2&amp;quot;&amp;gt;
  &amp;lt;buffer-cache name=&amp;quot;default&amp;quot;/&amp;gt;
  &amp;lt;server name=&amp;quot;default-server&amp;quot;&amp;gt;
    &amp;lt;http-listener name=&amp;quot;default&amp;quot; 
      socket-binding=&amp;quot;http&amp;quot;/&amp;gt;
    **&amp;lt;https-listener name=&amp;quot;default-ssl&amp;quot; 
        socket-binding=&amp;quot;https&amp;quot;
        security-realm=&amp;quot;SslRealm&amp;quot;/&amp;gt;**
    ...
&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>MailSession for WildFly 8 and GMail</title>
    <link href="https://jollobajano.com/posts/programming/2015-12-05-wildfly-mailsession.html"/>
    <id>https://jollobajano.com/posts/programming/2015-12-05-wildfly-mailsession.html</id>
    <updated>2015-12-05T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>Firstly, add the ourbound sockets for GMail SMTP and IMAP to standalone.xml:</summary>
    <content type="html">&lt;p&gt;Firstly, add the ourbound sockets for GMail SMTP and IMAP to &lt;code&gt;standalone.xml&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;
    &amp;lt;socket-binding-group name=&#34;standard-sockets&#34; default-interface=&#34;public&#34; port-offset=&#34;${jboss.socket.binding.port-offset:0}&#34;&amp;gt;
    ...
    &amp;lt;outbound-socket-binding name=&#34;mail-smtp&#34;&amp;gt;
    &amp;lt;remote-destination host=&#34;smtp.gmail.com&#34; port=&#34;465&#34;/&amp;gt;
    &amp;lt;/outbound-socket-binding&amp;gt;
    &amp;lt;outbound-socket-binding name=&#34;mail-imap&#34;&amp;gt;
    &amp;lt;remote-destination host=&#34;imap.gmail.com&#34; port=&#34;993&#34;/&amp;gt;
    &amp;lt;/outbound-socket-binding&amp;gt;
    &amp;lt;outbound-socket-binding name=&#34;mail-smtp-25000&#34;&amp;gt;
    &amp;lt;remote-destination host=&#34;localhost&#34; port=&#34;25000&#34;/&amp;gt;
    &amp;lt;/outbound-socket-binding&amp;gt;
    ...
    &amp;lt;/socket-binding-group&amp;gt;
    &amp;lt;/server&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Then add the &lt;code&gt;mail-session&lt;/code&gt;element:&lt;/p&gt;
&lt;pre&gt;
        &amp;lt;subsystem xmlns=&#34;urn:jboss:domain:mail:2.0&#34;&amp;gt;
            &amp;lt;mail-session name=&#34;gmail&#34; jndi-name=&#34;java:jboss/mail/Gmail&#34;&amp;gt;
                &amp;lt;smtp-server outbound-socket-binding-ref=&#34;mail-smtp&#34;
                 ssl=&#34;true&#34; username=&#34;${gmail.username}&#34;
                 password=&#34;${gmail.password}&#34;/&amp;gt; 
                &amp;lt;custom-server name=&#34;imap&#34;
                   outbound-socket-binding-ref=&#34;mail-imap&#34;
                   ssl=&#34;true&#34; username=&#34;${gmail.username}&#34;
                   password=&#34;${gmail.password}&#34;&amp;gt;
                    &amp;lt;property name=&#34;connectiontimeout&#34; value=&#34;30000&#34;/&amp;gt;
                    &amp;lt;property name=&#34;timeout&#34; value=&#34;30000&#34;/&amp;gt;
                &amp;lt;/custom-server&amp;gt;
            &amp;lt;/mail-session&amp;gt;
        &amp;lt;/subsystem&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Restart.&lt;/p&gt;
&lt;p&gt;Now, well try the connection, using the following servlet:&lt;/p&gt;
&lt;pre&gt;
package jollobajano.sendmail;
import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;

import javax.mail.Session;
import javax.mail.Message;
import javax.mail.Transport;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.annotation.Resource;

@WebServlet(value=&#34;/mail&#34;)
public class SendmailServlet extends HttpServlet
{
    @Resource(mappedName=&#34;java:jboss/mail/Gmail&#34;)
    private Session mailSession;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        {

            PrintWriter out=response.getWriter();
            try    {
                MimeMessage m = new MimeMessage(mailSession);
                Address from = new InternetAddress(&#34;AN EMAIL ADDRESS&#34;);
                Address[] to = new InternetAddress[] {new InternetAddress(&#34;ANOTHER EMAIL ADDRESS&#34;) };

                m.setFrom(from);
                m.setRecipients(Message.RecipientType.TO, to);
                m.setSubject(&#34;JBoss AS 7 Mail&#34;);
                m.setSentDate(new java.util.Date());
                m.setContent(&#34;Mail sent from JBoss AS 7&#34;,&#34;text/plain; charset=utf-8&#34;);
                Transport.send(m);
                out.println(&#34;Mail sent!&#34;);
            }
            catch (javax.mail.MessagingException e)
            {
                e.printStackTrace();
                out.println(&#34;Error in Sending Mail: &#34;+e);
            }
        }
    }
}
&lt;/pre&gt;</content>
  </entry>
  <entry>
    <title>Can I use my existing git repo with openshift? (Stackoverflow)</title>
    <link href="https://jollobajano.com/posts/programming/2015-10-15-can-i-use-my-existing-repo-with-openshift.html"/>
    <id>https://jollobajano.com/posts/programming/2015-10-15-can-i-use-my-existing-repo-with-openshift.html</id>
    <updated>2015-10-15T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>I copied this from a StackOverflow post for my own convenience.</summary>
    <content type="html">&lt;p&gt;I copied this from a StackOverflow post for my own convenience.&lt;/p&gt;
&lt;p&gt;From &lt;a href=&#34;http://stackoverflow.com/questions/12657168/can-i-use-my-existing-git-repo-with-openshift&#34;&gt;Can I use my existing git repo with openshift? (Stackoverflow)&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;As you&#39;d do with git in general, the approach to choose here is to
clone your other git repo (ex. on bitbucket) to your local machine:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;git clone &amp;lt;bitbucket-repo-url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your local clone has then your other repo (bitbucket etc.) as remote
repo. Your remote repo is stored with the alias &#34;origin&#34; (the default
alias used by git if you clone). You then add the openshift repo as
remote to your clone. You do that while explicitly using an alias for
the remote repo you add - I&#39;m using &#34;openshift&#34; as alias here:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;git remote add openshift -f &amp;lt;openshift-git-repo-url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In order to then be able to push the code from your local git repo to
openshift you first have to merge your openshift repo with your local
bitbucket clone. You do that by issuing locally:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;git merge openshift/master -s recursive -X ours
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this command you tell git to merge the master branch in the
openshift git repo with your local git repo. You tell it to merge
using the recursive merging strategy and to choose your (&#34;ours&#34;)
version when there are conflicts.&lt;/p&gt;
&lt;p&gt;Once the merge is executed you&#39;re ready to push your git repo to
openshift. You do that by doing:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;git push openshift HEAD
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You tell git to push your local code to the HEAD branch on the remote
repo called &#34;openshift&#34; (the alias we stored the openshift git repo
at, some paragraphs further up).&lt;/p&gt;
&lt;p&gt;btw. I wrote a jboss tools blog which was demonstrating how to use the
openshift-java-client some months ago:
https://community.jboss.org/wiki/Enable-openshift-ciFullExampleUsingOpenshift-java-client
. You&#39;ll spot the above steps in the last paragraph &#34;We&#39;re almost
there&#34;.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>mod_perl compiled</title>
    <link href="https://jollobajano.com/posts/programming/2015-02-22-mod_perl-compiled.html"/>
    <id>https://jollobajano.com/posts/programming/2015-02-22-mod_perl-compiled.html</id>
    <updated>2015-02-22T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>I finally compiled mod_perl. Stuck with my MacBookPro there were some extra problems to tackle.</summary>
    <content type="html">&lt;p&gt;I finally compiled mod_perl. Stuck with my MacBookPro there were some extra problems to tackle.&lt;/p&gt;
&lt;p&gt;This here, for instance:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&#34;http://blogs.perl.org/users/jason_a_crome/2012/04/compiling-mod-perl-2-on-os-x-lion.html&#34;&gt;&lt;strong&gt;Compiling mod_perl 2 on OS X Lion&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By &lt;em&gt;Jason A. Crome on April 3, 2012 5:20 PM&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Since updating to the latest XCode on OS X Lion, we&amp;#8217;ve been unable to build or use mod_perl 2 on our development machines. If we ignore the test failures and make install anyhow, we get this error message when trying to start Apache:&lt;/p&gt;
&lt;p&gt;&lt;pre &gt;Cannot load /opt/local/apache2/modules/mod_perl.so into server:dlopen(/opt/local/apache2/modules/mod_perl.so, 10): Symbol not found:_modperl_handler_anon_add&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;One of our developers discovered this morning that llvm/clang on OS X defaults to C99, but mod_perl expects the 89 &amp;#8220;standard&amp;#8221;. As a result of this thread, we compiled mod_perl in the following manner:&lt;/p&gt;
&lt;p&gt;&lt;pre&gt;$ perl Makefile.PL MP_APXS=/path/to/apache/bin/apxs MP_CCOPTS=-std=gnu89
$ make
$ make test
$ make install&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And voila, we have a working mod_perl 2 on Lion.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Finally I tried the two &lt;em&gt;mod_perl invoking strategies in&lt;/em&gt; &lt;a href=&#34;http://perl.apache.org/docs/2.0/user/intro/start_fast.html#Configuration&#34;&gt;Get your feet wet with mod_perl&lt;/a&gt; which worked.&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Apache serving LaTeX files as rendered PDFs using a Bash script handler</title>
    <link href="https://jollobajano.com/posts/programming/2015-01-30-apache-serving-latex-files-as-rendered-pdfs-using-a-bash-script-handler.html"/>
    <id>https://jollobajano.com/posts/programming/2015-01-30-apache-serving-latex-files-as-rendered-pdfs-using-a-bash-script-handler.html</id>
    <updated>2015-01-30T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>/* CRUDE */</summary>
    <content type="html">&lt;p&gt;/* CRUDE */&lt;/p&gt;
&lt;p&gt;I thought I&amp;#8217;d start logging my daily [geekie]
explorations. I&amp;#8217;m comming out at this and believe this will be
crappy at some degree. I&amp;#8217;m also guessing I&amp;#8217;ll be better at
this over time. This is first time out so bare with me.&lt;/p&gt;
&lt;p&gt;I had this idea for years. To have apache render LaTeX files as
rendered PDF files. Many have had the idea but their often met by
objections that the Tex family programs use and produce files beside
the rendered file.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m using&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Apache web server&lt;/li&gt;
&lt;li&gt;Bash a the script engine&lt;/li&gt;
&lt;li&gt;LaTeX as my renderer. I could make this fancier by grep&amp;#8217;ing
    the .tex file for clues like &amp;#8220;\documentclass&amp;#8221; and
    &amp;#8220;\usepackage{fontspec}&amp;#8221; but this is just a PoC and not
    a full-fledged technical sollutio.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My solution builds on&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A LaTeX rendering CGI script.&lt;/li&gt;
&lt;li&gt;Some Apache configuration.&lt;/li&gt;
&lt;li&gt;Using the *nix mktemp command and LaTeX&amp;#8217;s
    &amp;#8211;output-directory option for the rendering.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In my daily doings I&amp;#8217; a Java-ist by birth and a terrible
Bash&amp;#8217;er so comments on my scripting style are probably
justifies.&lt;/p&gt;
&lt;p&gt;I had to check up on error-handling, the old HTTP environment
variables as well as bash file tests and more.&lt;/p&gt;
&lt;p&gt;The bash script goes, however, as follows:&lt;/p&gt;
&lt;pre&gt;#!/bin/bash -e

STATUS500=&#34;Status 500 internal server error&#34;
STATUS404=&#34;Status 404 file not found&#34;


function removeTempDirectory {
  [ -d &#34;$DIR&#34; ] &amp;#038;&amp;#038; rm -Rf $DIR
}

function die {
    removeTempDirectory
    printf &#34;$*\n\n&#34; 1&gt;&amp;#038;2
    trap - EXIT
    exit 1
}

PDFLATEX=`which pdflatex`
PDFLATEX_OPTIONS=&#34;-halt-on-error&#34;
[ -x &#34;$PDFLATEX&#34;  ] || die $STATUS500

DIR=`mktemp -d 2&gt;/dev/null || mktemp -d -t &#39;cgilatex&#39;`
[ -d &#34;$DIR&#34; ] || mkdir -p $DIR || die $STATUS500

[ -f $PATH_TRANSLATED ] || die $STATUS404

$PDFLATEX -halt-on-error \
    -interaction=nonstopmode \
    -output-directory=$DIR \
    $PATH_TRANSLATED &amp;#038;&gt; /dev/null || \
    die $STATUS500

printf &#34;Content-Type: application/pdf\n\n&#34;
cat $DIR/*.pdf

removeTempDirectory
exit&lt;/pre&gt;

&lt;p&gt;The extra Apache configuration to let the web server serve .tex files
through the bash script is done locally for this project but could
just as well have been made globally in the httpd.conf.&lt;/p&gt;
&lt;pre&gt;&amp;lt;Directory &#34;/.../cgilatex&#34;&amp;gt;
    Options +Indexes +ExecCGI
    Action pdflate-action /cgilatex/cgilatex.cgi
    AddHandler pdflate-action .tex
&amp;lt;/Directory&amp;gt;&lt;/pre&gt;

&lt;p&gt;The example LaTeX document was a hand crafted Lorem ipsum and goes something like this&lt;/p&gt;
&lt;pre&gt;\documentclass[a4paper,12pt]{article}
\title{CGILatex}
 \author{Mats Nyberg}
 \begin{document}
\maketitle

 Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do
 eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad
 minim veniam, quis nostrud exercitation ullamco
laboris nisi ut
 aliquip ex ea commodo consequat. Duis aute irure
dolor in
 reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla
 pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in
 culpa qui officia deserunt mollit anim id est
laborum.&#34;

 Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do
 eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad
 minim veniam, quis nostrud exercitation ullamco
laboris nisi ut
 aliquip ex ea commodo consequat. Duis aute irure
dolor in
 reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla
 pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in
 culpa qui officia deserunt mollit anim id est
laborum.
 \end{document}
 &lt;/pre&gt;

&lt;p&gt;Entering&lt;/p&gt;
&lt;pre&gt;$ PATH_TRANSLATED=test.tex ./cgilatex.cgi # spews out a PDF text&lt;/pre&gt;

&lt;pre&gt;$ PATH_TRANSLATED=test2.tex ./cgilatex.cgi # returns a 404 status&lt;/pre&gt;

&lt;pre&gt;$ PATH_TRANSLATED=error.tex ./cgilatex.cgi # returns a 500 status&lt;/pre&gt;

&lt;p&gt;to see the three different cases that could occur.&lt;/p&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;p&gt;https://github.com/jollobajano/cgilatex&lt;/p&gt;
&lt;p&gt;http://linuxcommand.org/wss0150.php&lt;/p&gt;
&lt;p&gt;http://linuxcommand.org/wss0160.php&lt;/p&gt;
&lt;p&gt;http://tldp.org/LDP/abs/html/fto.html&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Democracy Now video RSS feed add-on for the XBMC/Kodi media center</title>
    <link href="https://jollobajano.com/posts/programming/2015-01-23-democracy-now-video-rss-feed-add-on-for-the-xbmckodi-media-center.html"/>
    <id>https://jollobajano.com/posts/programming/2015-01-23-democracy-now-video-rss-feed-add-on-for-the-xbmckodi-media-center.html</id>
    <updated>2015-01-23T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>In an effort to start learning/using Python programming language I just happened to put together a XBMC/Kodi add-on that connects the media center with the Democracy Now RSS feed of their daily…</summary>
    <content type="html">&lt;p&gt;In an effort to start learning/using Python programming language I
just happened to put together a XBMC/Kodi add-on that connects the
media center with the Democracy Now RSS feed of their daily
broadcasts.&lt;/p&gt;
&lt;p&gt;The project is published on GitHub as a public git repository is a
requirement of the XBMC/Kodi community.&lt;/p&gt;
&lt;p&gt;The link to the repository
is &lt;a href=&#34;https://github.com/jollobajano/plugin.video.democracynow&#34; title=&#34;https://github.com/jollobajano/plugin.video.democracynow&#34;&gt;https://github.com/jollobajano/plugin.video.democracynow&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://kodi.tv&#34; title=&#34;http://kodi.tv&#34;&gt;Kodi.tv&lt;/a&gt; is the place to read about the Kodi project, formelly
known as XBox Media Center.&lt;/p&gt;
&lt;p&gt;Democracy Now! publishes on &lt;a href=&#34;http://democracynow.org&#34; title=&#34;http://democracynow.org&#34;&gt;democracynow.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>Rezzepy web application, Python starter project</title>
    <link href="https://jollobajano.com/posts/programming/2015-01-12-recipy-web-application-python-starter-project.html"/>
    <id>https://jollobajano.com/posts/programming/2015-01-12-recipy-web-application-python-starter-project.html</id>
    <updated>2015-01-12T00:00:00Z</updated>
    <category term="programming" label="Programming"/>
    <summary>I thought I’d finally strat using the blog.</summary>
    <content type="html">&lt;p&gt;I thought I&amp;#8217;d finally strat using the blog.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m teaching myself Python and my starter project is a rudimentary MVC web application &amp;#8220;framework&amp;#8221;. I&amp;#8217;m calling it Rezzepy.&lt;/p&gt;
&lt;p&gt;I usually never start documenting until the end of projects which always been too late. This time I&amp;#8217;m trying somethin different.&lt;/p&gt;
&lt;p&gt;The web application is built on&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;python (of course)&lt;/li&gt;
&lt;li&gt;wheezy template engine&lt;/li&gt;
&lt;li&gt;peavey ORM package&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</content>
  </entry>
</feed>