Updates from April, 2019 Toggle Comment Threads | Keyboard Shortcuts

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

    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.

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

    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: osx,   

    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:

    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 …).

     
  • penguin 10:52 on 2017-01-21 Permalink | Reply
    Tags: blog, code, wordpress   

    Syntax highlighting with wordpress 

    This is just a test for syntax highlighting. Which I really really really wanted to have. Even if it’s WordPress and not something cool like hugo.

    So, let’s try:

    That doesn’t look so bad, right?

    How to do this

    • install the crayon syntax highlight plugin
    • when writing posts, your toolbar will have a new icon looking like this: <>
    • press it, and an “add code” dialog will open
    • do your thing
    • save
    • done

    Like.

    Dislikes

    • I don’t know which JS engine this thing uses (if any public one in particular)
    • I like highlight.js

    (So, none really)

    Alternative plugins (untested)

    To be honest, the only real contender in installation base and features seems to be Syntax Highlighter Evolved. I have not tried it, but if you don’t like crayon, that looks like the one to go.

     
  • penguin 11:27 on 2016-01-29 Permalink | Reply
    Tags: ,   

    Really annoying thread properties 

    This sucks monkey ass, mainly because I didn’t think of that before. And that’s just one example why multi-threaded (soon to be -processing, probably) applications are hard.

    [code]import subprocess as sp
    import time
    import os
    from threading import Thread

    class MyThread(Thread):

    def __init__(self, mydir):
    super().__init__()
    self.mydir = mydir

    def run(self):
    os.chdir(self.mydir)
    time.sleep(2)
    print("I’m (%s) in directory %s"
    % (str(self), os.getcwd()))

    if __name__ == "__main__":
    MyThread("/tmp").start()
    time.sleep(1)
    MyThread("/").start()
    [/code]

    Result is:

    [code]I’m (<MyThread(Thread-1, started 140195858716416)>) in directory /
    I’m (<MyThread(Thread-2, started 140195850323712)>) in directory /[/code]

     
  • penguin 17:32 on 2015-12-25 Permalink | Reply  

    Mac software essentials 

    Well, after the Firefox Essentials, here’s my list of Mac essentials:

     
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