Tuesday, December 20, 2022

Reviving my web site

 It's been years since I updated or even used this blog, but now I going to revive it.

Necromancer Rathma icon from Diablo 3

First of all - I have updated the design (to another booring design), but I do not have the time to tweek everything right now.

Second I have added HTTPS. This was much needed.

Third: As Twitter is burning down, I also have revieved my life on Mastodon, and are much more active. Also because a lot of new danish profiles are moving to Mastodon. But to get my account verified, I needed to add e <REF tag to my web site. So I have to admit - this was the primary reason for reviving this site again :-)

Saturday, June 29, 2019

Summer drinks

Aperol sweet spritz
  • 2 part Aperol
  • 1 part Sugar cane (or Orange syrup
  • 3 part Dry white wine
  • 2 part Club soda
  • Ice

Sunday, March 31, 2019

Time Input Fields in PowerApps

When programming anything with time in Microsoft PowerApps, there seems to be no easy way to create a time field, that is able to input and validate time.


I have crated a script, that validates and formats a standard input field as a time field. This is working with 24h time, but it should give you an idea so you can expand it to whatever you want.

Create a text field, called "TimeInput".
Add the variable tTxtOut as "default" and the script below to "onChange". Set "HintText" to "hh:mm"

You can use the global variables in other parts of your code:
err: boolean - set to true if something is wrong
tTimeError: string - contains an error text  ("Invalid time!")
tTxtOut: string - contains the formattet time. Set the

Code:

// Set global variables

Set(inp, TimeInput.Text);
Set(th, "00");
Set(tm, "00");
Set(err, false);
Set(tTimeError, "");

//Validate length
If (Len(inp)>5, Set(err, true));

// Easy input without ":"
If (Len(inp)=3, Set(inp, Left(inp,2)&":"&Right(inp,1)&"0")); 
If (Len(inp)=4, Set(inp, Left(inp,2)&":"&Right(inp,2)));

// Validate hours
// Check for invalid characters
Set(th, First(Split(inp,":")).Result);
Set(h, Value(th));
If (th<>Text(h) And th<>"0"&Text(h), Set(err, true));
// Check limits
Set(th, Text(h));
If(h<0 Or h>23,Set(err, true));
If(h<10, Set(th, "0"&h));

// Validate minutes
// Check for invalid characters
Set(tm, Last(Split(inp,":")).Result);
Set(m, Value(tm));
If (tm<>Text(m) And tm<>"0"&Text(m), Set(err, true));
If(Find(":", inp)>0,m=m,Set(m, 0));
// Check limits
Set(tm, Text(m));
If(m<0 Or m>59, Set(err, true));
If(m<10, Set(tm, "0"&m));

// Do something
If(err, Set(tTimeError, "Invalide time!");Set(tTxtOut,inp), Set(tTxtOut, th&":"&tm))

Thursday, November 2, 2017

Organize your business cards

If you receive a lot of business cards, it can be a pain to keep them organized and available when you actually need them. To solve this problem I have found a solution using OneNote and Office Lens.

 



First you need a Live account (Microsoft)

Now log on to OneNote (or use the OneNote App on your phone or PC)

Create a new Notebook called "Business Card"


If you want to organize your business cards into groups, create a new section per group. I'm using a section for different projects and a section per exhibition I'm attending. I also have a "General" section for everything else.



Install Office Lens:


Connect Office Lens to your Live Account.

Use Office Lens to take a photo of the Business Card, using "Business Card" mode:

Now just press "Save" (Sorry for the danish text). Do NOT add additional images - this is not working.

You can change the name to something saying, but I always leave it as-is and then change it afterwards in OneNote.
Select the OneNote notebook and section you created previously.

Now you get to view a log with 2 new entries. Using this it is possible to open the new entry in OneNote, but also it is possible to open the actual contact information directly and import this to your contact list.



Extra tip:

When ever I use this, I also take a photo of the person I have spoken to and uploads this the same way. And if I got a brochure - I use the Office Lens document mode to upload this. This way I can connect the businees card with the face and information about what this was about.

Monday, October 23, 2017

Controlling Philips hue - using javaScript


Controlling your Philips hue by javascript is quite simple.

You'll need two things:

  • The IP address of your hue bridge
  • Your personal ID to the hue bridge
To obtain your ID, use this guide.

Copy the following code to a html-file, and change the 3 "vars" in the top:





<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Controlling hue</title>
</head>
<body>

<script type="text/javascript">
    // See API documentation to retrieve your own ID
    // https://www.developers.meethue.com/documentation/getting-started
    
    var hueIP = "x.x.x.x" // Your hue bridge IP
    var hueID = "123123123-b1b1b1b" // Get your ID from the hue bridge
    var hueLamp = "1" // the lamp to comtrol


    function callback() {}

    function send(obj) {
        var xmlhttp = new XMLHttpRequest();
        var url = "http://"+ hueIP +"/api/"+ hueID +"/lights/"+ hueLamp +"/state/";
        xmlhttp.open("PUT", url, true, callback);
        xmlhttp.setRequestHeader("Content-type", "application/json");    
        var parameters = JSON.stringify(obj);
        xmlhttp.send(parameters);
    }


    function turnOn() {
        send({"on":true})
    }

    function turnOff() {
        send({"on":false})
    }

    function turnRed() {
        send({"colormode": "xy", "xy": [
            0.7006,
            0.2993
        ]})
    }
    function turnGreen() {
        send({"colormode": "xy", "xy": [
            0.1724,
            0.7468
        ]})
    }
    function turnBlue() {
        send({"colormode": "xy", "xy": [
            0.1355,
            0.0399
        ]})
    }

    function turnPink() {
        send({"colormode": "hue", "hue": 25400, "sat": 254})
    }
    function turnPurple() {
        send({"colormode": "hue", "hue": 10400, "sat": 254})
    }


    function turn50() {
        send({"bri": 127})
    }
    function turn100() {
        send({"bri": 254})
    }

    function turnCool() {
        send({"colormode": "ct", "ct": 154})
    }
    function turnWarm(){
        send({"colormode": "ct", "ct": 500})
    }

    function turnColor() {
        send({"effect": "colorloop"})
    }

</script>

<h2>On/off:</h2>
<button onclick="javascript:turnOn()">On</button>
<button onclick="javascript:turnOff()">Off</button>
<br>
<h2>Color using xy:</h2>
<button onclick="javascript:turnRed()">Red</button>
<button onclick="javascript:turnGreen()">Green</button>
<button onclick="javascript:turnBlue()">Blue</button>
<br>
<h2>Color using hue:</h2>
<button onclick="javascript:turnPink()">Pink</button>
<button onclick="javascript:turnPurple()">Purple</button>
<br>
<h2>Brightness:</h2>
<button onclick="javascript:turn50()">50%</button>
<button onclick="javascript:turn100()">100%</button>
<br>
<h2>Warm/cold light:</h2>
<button onclick="javascript:turnCool()">Cool</button>
<button onclick="javascript:turnWarm()">Warm</button>
<br>
<!-- <button onclick="javascript:turnColor()">Color loop</button> -->

    
</body>
</html>

Thursday, September 29, 2016

Using Pebble Tasker for Android

If you ever wished there was a way to automate some processes on your phone - no worries - just make the a "script" with Tasker.
Tasker works a little like ITFFF - but you can do SO much more - you can even make your script into an App and sell it.
Sorry to say - the application "Tasker" doesn't exist on iPhone!

Get the apps

First of all - you have to buy and install Tasker and Pebble Tasker on your phone.


Tasker
Pebble Tasker






Tasker is a script engine. It makes it possible for you to add new functions to your phone, almost only with your imagination as the limit. It's ultimately possible to export tasker scripts as an application so you can "program" an application you can share.

To use the scripts you make in Tasker, you have to use Pebble Tasker. This gives you direct access to up to 25 script using the 3 buttons on the right. And you can use Tasker to change the Pebble button functions on-the-fly, making the number of tasks much higher. 

Be aware that Tasker will run 24/7 in the background so you should expect your battery time to decrease. It is possible to disable Tasker if you prefer longer battery time from time to time. Actually you can make a Tasker script, that disables Tasker.
Also notice that Tasker WILL slow your phone a bit. Actually I had to uninstall it on my Galaxy Nexus 3 because of that - but it runs fine on e.g. an old HTC One X.

Pebble and Tasker

Pebble is sold as a watch, but to me Pebble is so much more than just a watch - and when using an Android phone - the possibilities explodes because of the application "Tasker". 


Setting up Tasker

To read more about Tasker: See tasker.wikidot.com

Examples:


When I have the time - I'll add some description of script I have made...


And now for some simple scripts:

Read out the last text message (with Pebble)

When driving a car or walking the dog - it's not always possible to pick up the phone and read the text message that just arrived. So  lets start with a simple script that will read out the last text message received when you press a button on Pebble.


Dial a specific person




Dial a specific person - with acknowledged








Using Pebble Tasker for Android

If you ever wished there was a way to automate some processes on your phone - no worries - just make the a "script" with Tasker.
Tasker works a little like ITFFF - but you can do SO much more - you can even make your script into an App and sell it.
Sorry to say - the application "Tasker" doesn't exist on iPhone!

Get the apps

First of all - you have to buy and install Tasker and Pebble Tasker on your phone.


Tasker
Pebble Tasker






Tasker is a script engine. It makes it possible for you to add new functions to your phone, almost only with your imagination as the limit. It's ultimately possible to export tasker scripts as an application so you can "program" an application you can share.

To use the scripts you make in Tasker, you have to use Pebble Tasker. This gives you direct access to up to 25 script using the 3 buttons on the right. And you can use Tasker to change the Pebble button functions on-the-fly, making the number of tasks much higher. 

Be aware that Tasker will run 24/7 in the background so you should expect your battery time to decrease. It is possible to disable Tasker if you prefer longer battery time from time to time. Actually you can make a Tasker script, that disables Tasker.
Also notice that Tasker WILL slow your phone a bit. Actually I had to uninstall it on my Galaxy Nexus 3 because of that - but it runs fine on e.g. an old HTC One X.

Pebble and Tasker

Pebble is sold as a watch, but to me Pebble is so much more than just a watch - and when using an Android phone - the possibilities explodes because of the application "Tasker". 


Setting up Tasker

To read more about Tasker: See tasker.wikidot.com

Examples:


When I have the time - I'll add some description of script I have made...


And now for some simple scripts:

Read out the last text message (with Pebble)

When driving a car or walking the dog - it's not always possible to pick up the phone and read the text message that just arrived. So  lets start with a simple script that will read out the last text message received when you press a button on Pebble.


Dial a specific person




Dial a specific person - with acknowledged








Reviving my web site

 It's been years since I updated or even used this blog, but now I going to revive it. First of all - I have updated the design (to anot...