Updates from April, 2020 Toggle Comment Threads | Keyboard Shortcuts

  • penguin 23:18 on 2020-04-25 Permalink | Reply
    Tags: , , , nextcloud   

    nextcloud and Docker and reverse proxies 

    I have a nextcloud setup like described here (docker-compose, let’s encrypt proxy companion, postgres and nextcloud). And for a while I couldn’t connect any new nextcloud clients to the installation.

    This fixed it:

    <?php
    $CONFIG = array (
      # manually added because it's not picked up from
      # the env vars once set ... it seems ...
    
      # the docker IP range
      'trusted_proxies' => ["172.16.0.0/12"],
    
      # the hostname of the server
      'overwritehost'   => "my.super.secret.server",
    
      # the ENDUSER->PROXY protocol, NOT the proxy-> nextcloud protocol!
      'overwriteprotocol' => "https",
    
      #
      # AAAND NOW back to the original config file ...
      # ...
    )

    Some notes:

     
  • penguin 22:23 on 2020-04-16 Permalink | Reply
    Tags: camel, , , success   

    A more peaceful rant about Java & Camel 

    I did it. I feel like I survived something, like I am on the path on enlightenment (and it feels like raising the foot for the first step in a yourney which I know to be several AEs long). Anyway, I’m kinda happy.

    What did I do? I succeeded to write this Java code using the Apache Camel library (and yes, that’s it – in total):

    import org.apache.camel.main.Main;
    
    public final class CamelPusher {
    
        private CamelPusher() {
        }
    
        public static void main(String[] args) throws Exception {
            Main camelMain = new Main();
            // https://is.gd/P8SzKX
            camelMain.configure().withXmlRoutes("file:*.xml");
            camelMain.run(args);
        }
    
    }
    

    Impresive, huh?

    What took me longest was to add the “file:” in the line camelMain.configure().withXmlRoutes("file:*.xml");. Yup, really.

    Code-wise, that is. It took me even longer to set this up:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>de.company.business</groupId>
      <artifactId>camelocclient</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <name>CamelOCClient</name>
      <description>The thing that transfers payment files to OC</description>
    
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
    
      <repositories>
        <repository>
          <id>spring-releases</id>
          <url>https://repo.spring.io/libs-release</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>spring-releases</id>
          <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
      </pluginRepositories>
    
      <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>5.2.5.RELEASE</version>
        </dependency>
    
        <dependency>
          <groupId>org.apache.camel</groupId>
          <artifactId>camel-core</artifactId>
          <version>3.2.0</version>
        </dependency>
    
        <dependency>
          <groupId>org.apache.camel</groupId>
          <artifactId>camel-ftp</artifactId>
          <version>3.2.0</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-spring -->
        <dependency>
          <groupId>org.apache.camel</groupId>
          <artifactId>camel-spring</artifactId>
          <version>3.2.0</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
          <version>1.7.30</version>
        </dependency>
    
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>2.7</version>
            <configuration>
              <allowMajorUpdates>false</allowMajorUpdates>
              <!-- https://stackoverflow.com/a/22174801/902327 -->
              <!-- fucking maven shit honestly those java assholes suck so badly -->
              <rulesUri>file:///${project.basedir}/pom-versions-ruleset.xml</rulesUri>
            </configuration>
          </plugin>
          <plugin>
            <!-- see here: https://is.gd/HNFI0H -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.12.RELEASE</version>
            <executions>
              <execution>
                <goals>
                  <goal>repackage</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <groupId>org.codehaus.mojo</groupId>
            <executions>
              <execution>            <!-- Run our version calculation script -->
                <id>git-tag</id>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <executable>git</executable>
              <arguments>
                <argument>tag</argument>
                <argument>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}${parsedVersion.qualifier?}</argument>
              </arguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    
    </project>
    <!-- I FUCKING HATE MAVEN. -->
    

    And this, cause maybe I still don’t fully get maven (and with maybe I mean definitely, and yes I know there’s an error in the Makefile, I’m gonna fix it – later):

    all: clean build prepare-test test
    .PHONY: all
    
    clean:
        rm -rf tmp
    .PHONY: clean
    
    build:
        mvn package
    .PHONY: build
    
    prepare-test: clean
        mkdir -p tmp/from_here tmp/to_here tmp/and_from_here tmp/to_here_as_well
        echo deeply > tmp/from_here/i-want-to-be-moved.txt
        echo deeply > tmp/and_from_here/hashtag-metoo.txt
        cp target/camelocclient-SNAPSHOT.jar tmp/
        cp test-config.xml tmp/
    .PHONY: test
    
    test:
        cd tmp; pwd; java -cp . -jar camelocclient-SNAPSHOT.jar
    .PHONY: test
    
    run: test
    .PHONY: run
    
    .PHONY: _git_dirtycheck
    _git_dirtycheck:
        [[ ! -z "git status -s" ]] || (echo -e "\n\n***** working dir is dirty. *****\n\n" && false)
    
    .PHONY: _major
    _major: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.nextMajorVersion}.0.0 \
            versions:commit
    
    .PHONY: _minor
    _minor: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.nextMinorVersion}.0 \
            versions:commit
    
    .PHONY: _patch
    _patch: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.nextIncrementalVersion} \
            versions:commit
    
    .PHONY: _set_version
    _set_version: _git_dirtycheck
        read -p "new version: " VERSION ; \
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=$$VERSION \
            versions:commit
    
    .PHONY: _snap
    _snap: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.nextIncrementalVersion}-SNAPSHOT \
            versions:commit
    
    .PHONY: _tag
    _tag:
        git commit -am "Version bump"
        mvn build-helper:parse-version exec:exec
    
    .PHONY: _snap_tag
    _snap_tag: _snap _tag
    
    .PHONY: _addsnap
    _addsnap:
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.incrementalVersion}-SNAPSHOT \
            versions:commit
    
    .PHONY: _release
    _release: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.incrementalVersion} \
            versions:commit
    
    .PHONY: major
    major: _major _tag build _snap_tag
    
    .PHONY: minor
    minor: _minor _tag build _snap_tag
    
    .PHONY: patch
    patch: _patch _tag build _snap_tag
    
    .PHONY: addsnap
    addsnap: _addsnap
    
    .PHONY: rel
    rel: _release _tag build _snap_tag
    
    .PHONY: release
    release: rel
    
    .PHONY: set-version
    set-version: _set_version _tag build _snap_tag
    
    .PHONY: setver
    setver: set-version
    

    So this is it. That abomination took me days to build.

    So now I can do “make release“, get a .jar file, and place something like this next to it:

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
      DOKUMENTATION:
      https://camel.apache.org/manual/latest/spring.html
    -->
    
    <routes xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="file:from_here"/>
            <to uri="file:to_here"/>
        </route>
        <route>
            <from uri="file:and_from_here"/>
            <to uri="file:to_here_as_well"/>
        </route>
    </routes>
    

    … having a freely configurable, all-purpose, no-nonsense Camel engine to my disposal, which I can then deploy to any host of my liking to do things which are useful. In that case – it’s supposed to transfer files (the “left” side of the system, a couple of deployments) to S3, and then pull them out (the “right” side of it, one deployment) into a folder on a target machine.

    This is it, this is all, this is basically the most trivial use case ever invented, and it’s supposed to be replaced with something “real”. Let’s see how long it takes to get there.

    Now, am I happy? Yes. Is this … “good”? No. Does it work? Probably (it does with a file server / sftp transfer system).

    But the best part is: I kinda, sorta understand a little bit of what I did. And I am starting to think that Camel might actually be awesome, and maven actually useful – once you start understanding the concepts and ecosystem. But that’s just a vague possibility, given that I still don’t 😉 .

    I published the files here as well.

     
  • penguin 00:28 on 2020-01-11 Permalink | Reply
    Tags: , ,   

    cert-manager too old … 

    Today cert-manager stopped issuing certificates, and all requests said “insecure website”. Uncool, since this affected our Confluence and our sign-in mechanism. So let’s find out what was happening, right? Turns out cert-manager considered itself “too old” (“your ACME client is too old”, literally) and wanted to be updated.

    So far, so good. Just perform helm update cert-manager cert-manager, right?

    Wrong.

    • First, I had to upgrade to helm3. All right, I could have used helm2, but helm3 was already on here, and it seemed easy. That went (fairly) easy.
    • Then I wanted to upgrade cert-manager. Turns out for that I actually had to upgrade the running k8s version 1.12.x to 1.13.x … otherwise I’d get errors from the helm chart. That just took ages cause AKS is a bit slow.
    • Finally done I wanted to upgrade cert-manager. Until I realized a lot of stateful pods were stuck in “initialization”. Turns out that AKS had issues moving the volumes around, I still don’t know why. (Did I mention I just don’t like pretty much anything about Azure? It’s just so incredibly cumbersome to use, and nothing is where you expect it). So I had to manually mount the volumes on the host the Pod was currently on and have an open TODO now, which just sucks.
    • Finally done I wanted to upgrade cert-manager. The upgrade went just peachy, until I realized that … nothing happened. Turns out they changed pretty much all API versions and annotation keys. So I had to rewrite / upgrade all ingress annotations, update the ClusterIssuer resources and delete the now obsolete former K8S CRDs.

    And just like that I had my certificates back. Wasn’t that easy? 😀

     

     
  • penguin 09:48 on 2019-04-19 Permalink | Reply
    Tags: ,   

    Windows after 13 years – and nothing changed 

    I have a Windows PC again, after about 13 years of abstinence and never looking back. (Why? Gaming. Once in 13 years is OK I guess).

    And nothing changed.

    Step 1: Uninstalling crap

    Uninstall those things from the Windows menu: Candy Crush, Cooking Fever, and three others I forgot to document. It’s a pristine ISO install, nothing from a vendor – I bought components myself, and I assembled myself. So this is Windows and Windows alone that’s to blame.

    And don’t forget all the crap which is in the Windows menu tiles – XBox & co, I mean you. (Removed about 7 super useless things here alone).

    Step 2: change mouse wheel direction

    Step 2: Change mouse wheel direction (sorry, Mac spoiled me). I can configure anything and everything in Windows – not that. Google helps, and I have to – of course – navigate the registry to find keys that look like this:

    HKLM\SYSTEM\CurrentControlSet\Enum\HID\...
    ... VID_046D&PID_C53D&MI_01&COL01\9&12BDBF6B&0&0000\...
    ... DeviceParameters\FlipFlopWheel

    (Set this to 1, and get the “VID_0…” whatever string from the “Advanced Settings” of the mouse properties dialogue. Brainfuck.

    Step 3: Disable cortana

    Oh yeah, disabling Cortana is almost easy (set this to 0):

    HKLM\SOFTWARE\Policies\Microsoft\Windows\...
    ... Windows Search\AllowCortana

    Step 4: Remove contacts icon from taskbar

    Removing the stupid “Contacts” icon on the task bar is super simple in contrast: Right-click, and uncheck “Show contacts”. Yay!

    Step 5: Re-login / Reboot

    Where the fuck can I log out?!

    Oh right, click the start menu, immediately see the unobtrusive grey junk icon which is supposed to be me in the leftmost area on top of all the other nondescriminate icons, click it, and see the menu pop up which offers to “log out”. How could I miss this.

    Summary

    Well, this is not all. This is just what I did today, after already tuning the system a while ago. In contrast Mac: Unpack, open (Laptops only here), start working. No candy crush removal necessary.

     
    • Nikolai 10:11 on 2019-04-19 Permalink | Reply

      One word: SteamPlay 🙂

  • penguin 09:56 on 2018-12-05 Permalink | Reply
    Tags: o365,   

    Powershell, O365 & Teams PSTN calling 

    Unfortunately you need a Windows system to administer Office 365 with PowerShell. It’s only API calls, but it’s not (yet, hopefully) migrated to .NET Core. So Mac & Linux users are out of luck, although .NET Core should be more than capable to do this.

    Anyhow.

    If you want to administer Teams with PowerShell, you … are in trouble. It’s barely documented, and it sucks. Those are the steps to be done:

    > $sess = New-CsOnlineSession ... 
    > Import-Module SkypeOnlineConnector ... 
    > Import-PSSession $sess

    … and this should be it. Now all the PowerShell commands for Teams (in my case: Grant-CsTeamsUpgradePolicy) should be available.

     
  • penguin 11:06 on 2018-10-17 Permalink | Reply
    Tags: , , ,   

    Misc Django I – forms 

    Custom form errors

    If you want to validate something in the view, and return with a custom error message in the same form, you can use the “Form.add_error(fieldname, errorstring)” method. And then, of course, return to the previous template.

    class MyView(View): 
        def get(self, request): 
            data = form.cleaned_data
            if len(res) > 0:
                form.add_error( 'login', "Diese Personalnummer existiert bereits!")
            return render(request, 'my_template.html', {'form': form})

    Dynamic choice fields in forms

    You want a form which fills its choice field from the database? And if the database changes, if you reload the page, the form should change as well? Of course! Django got you covered.

    class UserForm(forms.Form): 
        def __init__(self, *args, **kwargs):
            super(UserForm, self).__init__(*args, **kwargs) 
            self.fields['site'] = forms.ModelChoiceField( label="Site", queryset=Site.objects.all().order_by('name'), ) 
            for field in ('department', 'office', 'phone'):
                self.fields.move_to_end(field)
    
        login = forms.CharField(label="Login")
        email = forms.EmailField(label="Email")
        site = None # this is set in __init__() :)
        department = forms.CharField(label="Department")
        office = forms.CharField(label="Office")
        phone = forms.CharField(label="Phone")

    … now, why the “for field in (‘department’ …)” line you ask?

    Simple. The fields dict is an OrderedDict. If you replace a field it is appended to the end again. So in the form the “Site” input box would be displayed last, although it makes more sense to display it where it is in the original definition.

    Using “.move_to_end()” you can re-adjust this. If someone knows a better method … feel free to tell me.

    (Sources: here)

     
  • penguin 16:34 on 2018-10-16 Permalink | Reply
    Tags: , ,   

    Django, psql & “permission denied” on migrate 

    I got this error:

    psycopg2.ProgrammingError: permission denied for relation django_migrations

    … when I wanted to do a “python manage.py migrate”. This post had the solution. In short: You have to change the owner of the tables to the one specified in the Django configuration.

    This is how my script looks:

    #!/usr/bin/env bash
    echo "ALTER TABLE public.django_admin_log OWNER TO <new_owner>;" | psql -U <current_owner> <database>
    # ...

     

     
  • penguin 18:59 on 2018-09-26 Permalink | Reply
    Tags: ,   

    Firefox close tab buttons on mouse hover 

    I used to have Firefox’s TabMix Plus addon installed. And the feature I missed most – surprisingly – is to have the “close tab” buttons appear on a tab when you hover the mouse over it.

    Googling a little bit told me how to bring it back:

    .tabbrowser-tab:not([selected]):not([pinned]) .tab-close-button {
        visibility: hidden !important;
        margin-left: -16px !important;
    }
    .tabbrowser-tab:not([selected]):not([pinned]):hover .tab-close-button {
        visibility: visible !important; 
        margin-left: 0px    !important; 
        display: -moz-box   !important;
    }
     
  • penguin 18:55 on 2018-04-18 Permalink | Reply
    Tags: ,   

    Mac three finger gestures in browsers 

    Well, I *love* my three-finger-jump-to-top gesture in Firefox. It was gone.

    It took me about 2h to get it back by googling. And I blog so I don’t forget.

    Here’s where I should look next time straight away: System setting – Trackpad – rightmost tab – first setting.

     
  • penguin 20:11 on 2017-07-27 Permalink | Reply
    Tags: , cups,   

    CUPS is … weird 

    CUPS is the printing system developed by Apple which is now also in use on pretty much every other Linux / Unix / *BSD box there is. Unfortunately, the process of managing printers is way more painful than the process on Arch Linux. At least with my setup, which is i3 running in a weirdly crippled GNOME session.

    This is what you have to do to get CUPS working on your machine:

    $ pacman -S cups
    [...]
    $ usermod -aG sys MY_USER
    [...]
    $ systemctl enable org.cups.cupsd
    $ systemctl start org.cups.cupsd
    

    The magic is line 2 – adding your user to the sys group. If you don’t do this, you won’t be able to use the web interface at all. Which is a shame, since then you can’t do anything useful (install printers, manage jobs, etc …).

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel