<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Niklas Nihlén on Medium]]></title>
        <description><![CDATA[Stories by Niklas Nihlén on Medium]]></description>
        <link>https://medium.com/@nippe?source=rss-a32fa6190b9a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DtbylooFMKj0gnAms1Z_KA.jpeg</url>
            <title>Stories by Niklas Nihlén on Medium</title>
            <link>https://medium.com/@nippe?source=rss-a32fa6190b9a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 14:15:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nippe/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Conditional git configs]]></title>
            <link>https://medium.com/@nippe/conditional-git-configs-eda97fb5224f?source=rss-a32fa6190b9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/eda97fb5224f</guid>
            <dc:creator><![CDATA[Niklas Nihlén]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 08:47:12 GMT</pubDate>
            <atom:updated>2026-01-12T08:47:12.781Z</atom:updated>
            <content:encoded><![CDATA[<p>Since the begining of time, since I started using git that is. I’ve always had a global ~/.gitconfig file with some aliases, e-mail, name and whatnot.</p><p>Being a consultant working with different customers I always forget to change it when I switch client and on top of that many of my personal projects have niklas.nihlen@client-email in the commits.</p><p>Just about to change client now so I decided to look into it and found that git since version 2.13 supports something called <a href="https://git-scm.com/docs/git-config#_includes">Conditional Configuration Includes</a>. But since I have a hard time grocking git’s official documentation I’ll show a small example instead, for future me and whoever else is interested :).</p><h3>Scenario</h3><p>I have a new client named client-x and I want all git commits in the client-x folder and subfolders to have the e-mail address given to me byt the client niklas@client-x, for everyting else I want to keep my personal e-mail niklas@personal. My folderstructure looks like this:</p><pre>~/ <br>├── .gitignore <br>├── dev/<br> ├── personal-project-1<br> ├── personal-project-2<br> ├── personal-project-3<br> └── client-x<br>   ├── client-repo-1<br>   └── client-repo-n</pre><p>I still want all my aliases and stuff to be global. So I created a new .gitconfig file in the client directory ~/dev/client-x/.gitconfig just containing my client provided e-mail address:</p><pre>[user]<br>  email = niklas@client-x</pre><p>Then I updated my global ~/.gitconfg to make use of the [includeOf]:</p><pre>[user]<br>  name = Niklas Nihlén<br>  email = niklas@personal<br><br>[includeIf &quot;gitdir:~/dev/client-x/&quot;]<br>  path = ~/dev/client-x/.gitconfig</pre><p>Works like a charm I don’t need to remeber to switch e-mail addresses anymore!</p><p><em>Originally published at </em><a href="https://www.hardcoded.se/2021/04/05/conditional-git-configs/"><em>https://www.hardcoded.se</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eda97fb5224f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Update firmware on Particle Photon using the CLI]]></title>
            <link>https://medium.com/@nippe/update-firmware-on-particle-photon-using-the-cli-c9d043c73951?source=rss-a32fa6190b9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9d043c73951</guid>
            <category><![CDATA[particle]]></category>
            <category><![CDATA[iot]]></category>
            <dc:creator><![CDATA[Niklas Nihlén]]></dc:creator>
            <pubDate>Wed, 08 Jun 2016 14:45:22 GMT</pubDate>
            <atom:updated>2016-06-08T14:46:46.702Z</atom:updated>
            <content:encoded><![CDATA[<p>Before updating the firmware on Particle Photon was a bit tricky. You can use the Firmware updater app on Mac. However I tried a couple of times and never got it to work. Another way was to use the particle-cli but ut was a little messy. You had to download the firmware consisting of two files and the run particle commands with those files in the right order.</p><p>However, I just upgraded the the CLI tools (&amp;gt; npm install -g particle-cli) and discovered some new (at least to me) utility functions. Namely `particle upgrade`.</p><p>I connected a Particle Photon with USB, and ran it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSOEFkEC4bFWXCO2EbUXzA.png" /></figure><p>Really simple and worked like a charm!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9d043c73951" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Water level notifier - home IoT, sending text messages using a Particle Photon]]></title>
            <link>https://medium.com/@nippe/water-level-notifier-home-iot-sending-text-messages-using-a-particle-photon-f5cdd74efb9b?source=rss-a32fa6190b9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5cdd74efb9b</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[particle]]></category>
            <dc:creator><![CDATA[Niklas Nihlén]]></dc:creator>
            <pubDate>Wed, 11 May 2016 06:15:43 GMT</pubDate>
            <atom:updated>2016-05-11T06:34:34.154Z</atom:updated>
            <content:encoded><![CDATA[<p>So, I’ve been itching to do a little IoT project at home. Last thing I did was the a little “information radiator” telling us how long before the bus leaves (<a href="http://hardcoded.se/2015/11/06/a-nerds-way-of-keeping-track-of-when-the-next-bus-leaves/">here</a>). Now I wanted to do something else fun and useful.</p><p>So in the basement of our house we have a geothermal heating pump. When water gets warm and expands inside the pump it has to dispose of it. We don’t have a floor drain in that part of the cellar so it ejects the water into a jar. When it’s full I’ll empty it and put it back.</p><p>In order for me not to have to check if it’s full with regular intervals I put together the following solution. When the water level reaches a certain threshold I should get a text message telling me that it’s time.</p><h3>Parts used</h3><h4><strong>Parts needed</strong></h4><p>1 <a href="https://www.sparkfun.com/products/13774">Particle Photon microcontroller</a> - An arduinoish microcontroller with wifi on the chip and some neat cloud services around it that you can use if you want to (<a href="https://www.particle.io/manage">https://www.particle.io/manage</a>), I think they made my solution a bit easier so I used their cloud. I hade one laying around at home.</p><p>1 <a href="http://www.kjell.com/se/sortiment/el-verktyg/elektronik/arduino/moduler/vattensensor-for-arduino-p87889">Water sensor for arduino</a> - Cheap simple thing that returns different voltage depending on water level.</p><p>1 <a href="https://www.particle.io/">particle.io</a> account - for setting up webhooks</p><p><a href="https://docs.particle.io/guide/tools-and-features/cli/photon/">Particle CLI tool</a> — using it to register webhooks and get data from the device. So you probably can get on without it but I’ll use it in this article.</p><p><a href="http://www.kjell.com/se/sortiment/mobilt/fast-telefoni/installation/telekablar/installationskabel/modulkabel-vit-4-ledare-p55948">Module cable with 4 conductors</a>- You can use any cable, I had that laying around from erlier projects.</p><p>Soldering gear - you probably can make it work without using clamps or lab jumper cables.</p><h4><strong>Parts not needed but used</strong></h4><p>Experiment board - You can use a breadboard or just solder wires to pins and other wires.</p><p>PBC Connector - again you could just solder it on to pins.</p><p>Shrink tubes - I used to secure som of my amateurish soldering.</p><p>Zip tie - just to hold some stuff together</p><h3>Building the hardware</h3><p>I actually proofed the concept out using an Arduino Uno, a breadboard and some jumper cables. But when I set of to make the “real stuff” I started with soldering the connectors of the cable to the water sensor. Keep track of the colors! I used red for power, black for ground and green for signal (signal delivers different voltage depending on the water level). Then I put on some shrink plastic to secure the soldering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*J1WPbx73agBBf7iO8VrXkg.jpeg" /></figure><p>I decided to put a PBC connector on a prototypeing circuit board so that I simply can change the length or type of wire used for the water level sensor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*TQHXrmZz7KwvLbohrrnzIg.jpeg" /></figure><p>So to clarify the layout:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*KjmGhTxh4EyCVo8yG5DMuQ.jpeg" /></figure><p>This is my first, crude, prototype looked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IBhFhvRPJzgOxAPhWndc-Q.png" /></figure><p>I made it look a little bit more polished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZ4taMrj4QiOTZWvoQxieg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BygoWoCYqaixUPBypwcD-g.jpeg" /></figure><h3>Software</h3><p>So there is a few parts in this solution. Since particle.io has cloud services working with their devices and SDK available at <a href="https://particle.io/">particle.io</a>. I opted to use that instead of doing HTTP calls directly from the Particle Photon to Twilio to get it done faster. Here’s an overview of the solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MWeWTtDdiaY7KK1kYD8laQ.png" /></figure><h4>Setting up Twilio</h4><p>First of all you need to set up a twilio account at <a href="https://www.twilio.com/">https://www.twilio.com/</a>. When you’re logged in you need to deposit some money to be able to use Twilio. Then you need to accuire a phone number enabled for SMS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kWgm9rgA84o74wvCyVT8Q.png" /></figure><p>You need your twilio <strong>number</strong>, <strong>accountd sid</strong> and <strong>auth token</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjqE2uvs3yRwWXun51GODQ.png" /></figure><h4>Creating the Webhook</h4><p>Now we’re going to put the Twilio info to use when we are going to create a webhook in our Particle.io account. A particle webhook is a cloud service that acts as a bridge beteween your particle and the rest of the world. The Particle SDK provides nice utility abstractions for these. So all you have to do in your code (as we’ll see later on) is to call <strong>Particle.publish(“webhook-name”, “message”, 60, PRIVATE); </strong>Which is kinda neat.</p><p>The webhook file is pretty straight.</p><pre>{<br> “eventName”: “twilio”,<br> “url”: “<a href="https://api.twilio.com/2010-04-01/Accounts/ACfcbc51403eca0e5e2cc50fd0b84a4ff4/Messages">https://api.twilio.com/2010-04-01/Accounts/&lt;twilio key&gt;/Messages</a>&quot;,<br> “requestType”: “POST”,<br> “auth”: {<br> “username”: “&lt;twilio key&gt;”,<br> “password”: “&lt;secret&gt;”<br> },<br> “form”: {<br> “From” : “&lt;from number&gt;”,<br> “To” : “&lt;to number&gt;”,<br> “Body” : “{{SPARK_EVENT_VALUE}}”<br> },<br> “mydevices”: true<br>}</pre><p>Create a file named twilio-webhook.json like this.</p><pre>$ particle webhook create twilio-hook.json<br><br>Using settings from the file twilio-hook.json<br>Sending webhook request { uri: ‘/v1/webhooks’,<br> method: ‘POST’,<br> json:<br> { event: ‘twilio’,<br> url: ‘<a href="https://api.twilio.com/2010-04-01/Accounts/ACfcbc51403eca0e5e2cc50fd0b84a4ff4/Messages&#39;">https://api.twilio.com/2010-04-01/Accounts/&lt;KEY&gt;/Messages&#39;</a>,<br> deviceid: undefined,<br> requestType: ‘POST’,<br> mydevices: true,<br> eventName: ‘twilio’,<br> auth:<br> { username: ‘&lt;KEY&gt;’,<br> password: ‘&lt;SECRET&gt;’ },<br> form:<br> { From: ‘&lt;TWILIO FROM NUMBER&gt;’,<br> To: ‘&lt;THE NUBMER YOU WANT SMS TO&gt;’,<br> Body: ‘{{SPARK_EVENT_VALUE}}’ } },<br> headers: { Authorization: ‘Bearer 7d90b34725afede88ce0b6ec824712121212121212’ } }<br>Successfully created webhook with ID 573069bd3f3354c212121</pre><p>Now we have everything setup and need some code to get it running :). All code is available at <a href="https://github.com/nippe/waterlevel-notifier-particleio/tree/blogpost">https://github.com/nippe/waterlevel-notifier-particleio/tree/blogpost</a>.</p><h4>Code on the device</h4><p>First off I declare some variables and a method.</p><pre>int sendSms(String command);<br>const int DELAY_IN_SECONDS = 10*60; // 10 minutes<br>bool isMessageSent = false;<br>int waterThreshold = 2880;<br>int waterLevelPin = A1;<br>int waterLevel = 0;</pre><p><em>DELAY_IN_SECONDS</em> is how often to check the water level. <em>sendSms</em> is the method that calls the webhook, <em>waterLevelPin</em> defines which analog port I connected the water level sensor to and some values for water level and keeping track of text message status. Next the up, the setup:</p><pre>void setup() {<br> Particle.variable(“waterLevel”, waterLevel);<br> Particle.function(“sendSms”, sendSms);</pre><pre> pinMode(waterLevelPin, INPUT);<br> delay(1000);<br>}</pre><p>Using <em>Particle.variable</em> and <em>Particle.function</em> to expose a variable and a method to the Particle cloud service, for testing purposes. Setting the mode of the water level pin to input using <em>pinMode(..)</em>.</p><pre>void loop() {<br> getWaterLevel();<br> checkWaterLevel();<br> delay(DELAY_IN_SECONDS * 1000);<br>}</pre><pre>int getWaterLevel() {<br> waterLevel = analogRead(waterLevelPin);<br> return waterLevel;<br>}</pre><pre>int sendSms(String command) {<br> if(command.length() &gt; 0){<br> Particle.publish(“twilio”, command, 60, PRIVATE);<br> }<br> return 0;<br>}</pre><pre>void checkWaterLevel() {<br> int currentLevel = analogRead(waterLevelPin);<br> if(currentLevel &gt; waterThreshold) {<br>   if(!isMessageSent){<br>     char msg[255];<br>     snprintf(msg, sizeof(msg), “Dags att tömma vatten i källarn! Nivå: %d”, waterLevel);<br>     sendSms(msg);<br>     isMessageSent = true;<br>   }<br> }</pre><pre>if(isMessageSent &amp;&amp; (currentLevel &lt; waterThreshold)) {<br> isMessageSent = false;<br> sendSms(“Du har tömt ser jag, lysande polarn!”);<br> }<br>}</pre><p>A larger chunk of code this time. getWaterLevel() gets the value and puts it in a global variable just so I can monitor it through the particle cli.</p><p>checkWaterLevel() does the acuatl checking and sends a SMS if the current value is higher than the threshold and no message has been sent.</p><p>So no rocket science but a fun little project.</p><p>Then I ended up tweaking it a little adding a few LEDs and stuff just for fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BygoWoCYqaixUPBypwcD-g.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5cdd74efb9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>