Category Archives: New Stuff

News about site and in general

Force add file permission in git.

I was working on a Windows laptop with a repo originally created on Mac, and git arbitrary changed bash script file permission from 755 to 644.

I was able to change it back by updating git index

git update-index --chmod=+x script.sh

But I couldn’t commit this change, because as far as git was concerned nothing in the file changed. But I was able to force-add the change

git add --chmod=+x -- script.sh

After that I was able to commit and push the change.

Enable ActivityPub Plugin on Bitnami WordPress instance with LetsEncrypt

ActivityPub plugin is a very cool piece of WordPress addition. With this plugin installed users of Mastodon and other such federated platforms that support ActivityPub can follow your blog as if it were another instance on the Fediverse.

Unfortunately if you run a Bitnami instance of WordPress (for example one provided by AWS LightSail with LetsEncrypt service providing a TLS certificate for you site – you may encounter an incompatibility issue. LetsEncrypt uses /.well-known/acme-challenge path on your site for certificate validation, but ActivityPub plugin uses /.well-known/webfinger path to return relevant profile information. It conflicts with LetsEncrypt and the WebFinger path returns “404 – not found”.

Fortunately there is an easy fix. Continue reading →

Easily verify yourself on Mastodon with GitHub

Mastodon unlike Twitter doesn’t have official (or paid, thanks Elon Musk) verification badge for account profile, but it does offer a way to verify yourself – by placing following link tag into HTML of a website/page you own (your blog for example):

<a rel="me" href="https://your.instance/@YourHandle">Mastodon</a>

where “your.instance” and “@YourHandle” are the Mastodon server you use and your profile handle respectfully. But what if you want to verify yourself with your GitHub profile? An ideal place would be something like a README.md file. Unfortunately every link placed into a markdown file automatically gets rel="nofollow", so it’s a no-go. But there is a way to do this. Continue reading →

Export Dynamic LINQ to CSV

LINQ allows to perform various queries against different data structures. Wouldn’t it be great if you could easily export result of a LINQ query to CSV? Fortunately you can! This article by Scott Hanselman explain how and culminates in cool in its simplicity code:

namespace FooFoo
{
    public static class LinqToCSV
    {
        public static string ToCsv<T>(this IEnumerable<T> items)
            where T : class
        {
            var csvBuilder = new StringBuilder();
            var properties = typeof(T).GetProperties();
            foreach (T item in items)
            {
                string line = string.Join(",",properties
                      .Select(p => p.GetValue(item, null)
                      .ToCsvValue()).ToArray());
                csvBuilder.AppendLine(line);
            }
            return csvBuilder.ToString();
        }
   
        private static string ToCsvValue<T>(this T item)
        {
            if(item == null) return "\"\"";
   
            if (item is string)
            {
                return string.Format("\"{0}\"", item
                      .ToString().Replace("\"", "\\\""));
            }
            double dummy;
            if (double.TryParse(item.ToString(), out dummy))
            {
                return string.Format("{0}", item);
            }
            return string.Format("\"{0}\"", item);
        }
    }
}

Continue reading →

Fling a random insult at Trump after every tweet

Ok time to get political. I hate many things that Trump tweets these days and would love to reply to each tweet personally, but have neither time not desire to read his delusions. Fortunately in these modern times robots take many of our jobs. And this looked like a perfect job for a bot. Similarly to the bot described in the previous post it will be IFTTT + Scriptr combo. But this time in reverse, here’s intended flow:

  1. Twitter service at IFTTT detects when @realDonaldTrump tweets
  2. It triggers Maker service that makes HTTP request to Scriptr code
  3. Scriptr code generates random insult and posts a reply to Trump’s tweet

Here’s what IFTTT applet looks like: Continue reading →

Tweet images with Scriptr and IFTTT

Sev Trek

Looks like everybody is doing Twitter bots these days so I decided to try my hand on one as well. And it had to be something lighthearted – to let people’s mind off things for a while. Way back in early 2000s there was a funny parody comic of Star Trek called Sev Trek. Original site is gone now, but archive of images was saved at http://sevspace.com/stupidarchive/sevtrek.asp.htm. Images are numbered sequentially – ideal for automatic processing. My bot would tweet random images every couple hours.

To host bot’s script I decided to go with Scriptr which offers powerful JavaScript backend and multiple expansion modules. And IFTTT has a cool Twitter service, one that can tweet image from an URL. So the idea was:

  1. Code hosted at Scriptr generates URL pointing to an image at sevspace.com
  2. Code then call Maker service of IFTTT – custom service capable of accepting HTTP requests
  3. Maker service triggers Twitter service and passes URL of image it got from Scriptr code
  4. IFTTT Twitter service tweets the image

Continue reading →

Using FusionCharts in SSRS reports

Microsoft’s SSRS is pretty advanced reporting system with multitude of advanced features. SSRS also has charting capabilities, but it’s somewhat lacking compared to more advanced desktop or web charting suites

On the other hand FusionCharts offers very cool charting package with gazillion of chart types and very cool features. But it uses JavaScript engine and renders charts client-side only!

What if there was a way to marry the two technologies together – to render cool FusionCharts in advanced SSRS repots? Continue reading →

Simulating Pebble GPath in Rocky.js

RockyJS is a black magic voodoo from Pebble Dev team. It allows you to run your JavaScript code on the actual smartwatch (unlike PebbleJS that runs on the phone). When RockyJS debuted it ran as a simulation in a browser, but since then it matured and now runs in Pebble emulators and on actual hardware.

RockyJS changed drastically since that web release. It resembles C code less and takes more standardized JavaScript approach. During that transition some features were lost. One of them is Pebble GPath concept – a graphical object that consist of set of coordinates that you can freely move and rotate. In particular missing commands gpath_move_to, gpath_rotate_to and gpath_draw_outline that move, rotate and draw the GPath. When I was porting my first Pebble watchface to Rocky I used those extensively. You can read about that implementation complete with the source code here. But now the commands are gone and I needed a substitution. Continue reading →

Future Time – watchface for Pebble smartwatch

http://tinyurl.com/timefu

This is the face of the future.

Two faces actually – because you get both analog and digital face – and it’s up to you which one to use. You also get eight predefined color themes as well as ability to set each color individually. This face also provides weather and fitness tracking at your fingertips. And it just looks cool.

Key features:

– Digital or Analog face type selection
– Multiple color themes as well as custom color settings (or you can leave it on auto and the color will depend on battery level)
– Weather (powered by Forecast.io), Step Counter, Distance Walked, Sleep Hours
– Bluetooth Connect/Disconnect alert of configurable intensity with visual clue
– Battery level represented by percentage number as well as visually by outer perimeter of dots (also by watchface color – if in auto color mode).
– Visual step goals

$0.99

After installing watchface you have a 3-day trial period to explore all the features and different aspects. At the end of trial if you like Future Time and want to keep it – it’s just $1.50 USD via Kiezel Pay payment system, you will be prompted to enter code and follow few easy payment steps. Once purchased – the watchface is yours permanently, no matter what Pebble or what phone you use, as long as you keep the same Pebble account.

You will need to get free key for weather services at https://developer.forecast.io – this is one time procedure.

Design by Paul Joel http://www.pauljoel.com