Solution for Samsung Galaxy S8+ not saving proxy settings on Android 9

So Samsung introduced a weird bug with the latest update – when you enter proxy settings for your wifi (e.g. your Charles instance) it looks like the settings are saved but they are not – when you go back into proxy settings it’s set to None again.

A workaround solution is to forget the wifi and connect to it again, this time entering proxy settings at the same time as the wifi password. If you need to clear / change proxy settings – do it again.

Hopefully Samsung fixes this rather annoying behaviour!

Posted in Android, Work | Leave a comment

Generate POCOs.groovy – generate C# POCOs from table structure using JetBrains DataGrip

Use the Scripted Extensions menu available when right-clicking on a table in JetBrains DataGrip to run this script. It will then generate POCOs using the table structure. Save aa Generate POCOs.groovy.

import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil

 * Available context bindings:
 *   SELECTION   Iterable<DasObject>
 *   PROJECT     project
 *   FILES       files helper

packageName = "com.sample // TODO: change me!"
typeMapping = [
  (~/(?i)bit/)                          : "bool",
  (~/(?i)tinyint/)                      : "byte",
  (~/(?i)uniqueidentifier|uuid/)        : "Guid",
  (~/(?i)int|integer/)                  : "int",
  (~/(?i)bigint/)                       : "long",
  (~/(?i)char/)                         : "string",
  (~/(?i)varbinary|image/)              : "byte[]",
  (~/(?i)double|float|real/)            : "double",
  (~/(?i)decimal|money|numeric|smallmoney/)       : "decimal",
  (~/(?i)datetime|datetime2|timestamp|date|time/) : "DateTime",
  (~/(?i)datetimeoffset/)                         : "DateTimeOffset",
  (~/(?i)/)                                       : "String"

FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->
  SELECTION.filter { it instanceof DasTable && it.getKind() == ObjectKind.TABLE }.each { generate(it, dir) }

def generate(table, dir) {
  def className = csName(table.getName())
  def fields = calcFields(table)
  new File(dir, className + ".cs").withPrintWriter { out -> generate(out, className, fields) }

def generate(out, className, fields) {
  out.println "using System;"
  out.println ""
  out.println "namespace $packageName"
  out.println "{"
  out.println "\tpublic class $className"
  out.println "\t{"
  fields.each() {
    out.println "\t\tpublic ${it.type} ${} { get; set; }"
  out.println "\t}"
  out.println "}"

def calcFields(table) {
  DasUtil.getColumns(table).reduce([]) { fields, col ->
    def spec = Case.LOWER.apply(col.getDataType().getSpecification())
    def typeStr = typeMapping.find { p, t -> p.matcher(spec).find() }.value
    fields += [[
                 name : csName(col.getName()),
                 type : typeStr,
                 annos: ""]]

def csName(str) {
  str.replaceAll(/[^\p{javaJavaIdentifierPart}[_]]/, "_")
Posted in Uncategorized | Leave a comment

Indenting code in Visual Studio Code with VSCodeVim plugin

Here is the configuration I use for VSCodeVim to enable using Tab and Shift-Tab to indent and unindent code in normal and visual modes.

        "before": ["S-Tab"],
        "after": [],
        "commands": [
                "command": "editor.action.outdentLines",
                "args": []
        "before": ["Tab"],
        "after": [],
        "commands": [
                "command": "editor.action.indentLines",
                "args": []
Posted in Work | Tagged , | Leave a comment

Bash script to rename files given a text file with new filenames

Yesterday I found myself needing to rename a bunch of files given a text file with the new names, so I had to use some of my (few) bash skills. I’m sure I could have done it in fewer lines, but the bash script below did the job.


# v1.1
# ./ text.txt *.dat

if [ "$#" == "0" ]; then
    echo "./ names.txt \"*.dat\""
    exit 1


# read file line by line, store in array with leading number and .dat postfix
while read line; do
	fileNum=`printf "%02d" $((index+1))`
	names[index]="$fileNum. $line.dat" # Custom rename format
done < $namefile


if [ "$#" -ne "$namecount" ]; then
	echo "Number of files ($#) doesn't match number of lines in $namefile ($namecount)"
	exit 1

# rename input files to match lines in the array
for file in "${files[@]}" ; do
	file=$(printf "%q" "$file")
	newfile=$(printf "%q" "${names[index]}")
	eval "mv $file $newfile"
Posted in Mac, Work | Tagged , , | Leave a comment

ComHem TivoToGo krashar på iPad – lösning

This one is in Swedish, but if your TiVo app crashes when used to control your TiVo box – use Google translate to read the text below.

Sedan en tid tillbaka har TivoToGo börjaat krasha direkt vid start på min iPad. Efter ett fruktlöst samtal med ComHems support bestämde jag mig för att spåra ner problemet.

Det första jag märkte var att appen bara krashade när iPaden är ansluten till samma wifi som Tivo-boxen, om jag stängde av wifi på iPaden och startade på 3G så funkade appen. Jag kunde dock givetvis inte styra boxen vilket är en del av appens poäng.

Så appen och boxen pratar på något sätt, antingen direkt eller via ComHem. Jag bestämde mig för att ta reda på det och kickade igång WireShark. För att inte bråka med inställningarna för krypteringsnycklar tog jag bort lösenordet på min wifi access point… och VIPS så började appen funka och styra boxen! Märkligt! Jag satte tillbaka samma lösenord – crash igen. Tog bort lösenordet – funkar! Satte ett nytt lösenord – FUNKAR! Wtf?

Har inte orkat kolla noggrant men det såg inte heller ut som att det gick trafik mellan boxen och appen, kommunikationen verkar ske via ComHem. Använder de möjligen krypteringsnycklarna för det wifi iPaden är på för att identifiera ens nät? ComHem – kommentar? =)

Hur som helst, jag är för lat för att undersöka detta vidare, enda uppsidan skulle ju vara att kunna styra TiVon från ett annat LAN, inget jag är jätteintresserad av. Kontentan är:


Posted in iOS | Leave a comment

Karabiner Num Lock to Eject

Put this in your private.xml to remap Num Lock to Eject on your Mac running OSX

<?xml version="1.0"?>
    <name>Map NumLock to Eject</name>
    <autogen>--KeyToKey-- KeyCode::PC_KEYPAD_NUMLOCK, KeyCode::VK_CONSUMERKEY_EJECT</autogen>
Posted in Mac | Leave a comment

Screen Lock Disable Timer in Google Play!

Another Android app released to the Google Play Store!

Screen Lock Disable Timer allows you to disable your swipe or pattern screen lock (aka keyguard) temporarily. Useful if you need to turn your screen on and off repeatedly for a while and don’t want to unlock each time!


Posted in Android | Leave a comment

Restoring SharePoint 2010 content DB

To do this:
1. Stop the SharePoint 2010 Timer and SharePoint 2010 Tracing services
2. Kill any IIS processes:

 Get-Process -Name w3wp | Stop-Process

3. Restore

Posted in Uncategorized, Work | Tagged | Leave a comment

Fix for AuthManager(CommerceServer): Error reading Commerce Server administration database

The below exception is easily remedied by removing all entries that relate to Commerce Server authentication module from your web.config. You are probably not using that module. 🙂

[COMException (0x800a0cc1): AuthManager(CommerceServer): Error reading Commerce Server administration database. Check the AddressKeyName setting in the CSApp.ini file for the site and ensure that it refers to the name of a Commerce Server application that exists for the site. Site name: 'MySite' Application name: 'MySite' Auth resource property: 's_SecureHostname' HRESULT: 0x800A0CC1]

Posted in Work | Tagged | Leave a comment

Headset Menu for Android hits the Play Store

I now have an app in the Play Store for Android. It’s called Headset Menu and provides easy access to your music apps!

What does it do?

This is shown in your notification area when you connect your headset to your phone. Easy to pick the right app!


And this is the configuration screen:

Main screen

Check it out on Google Play!

Posted in Uncategorized | Tagged , | 1 Comment