Tag: tools

  • A big fucking rant about Java

    Well, I’m back to writing Java. It was supposed to be simple – an Apache Camel .jar file which just reads the route definitions from a nearby *.XML file in the same directory. So it can be re-used, because we have a couple of dead simple use cases which just require a Camel runtime and no special Java Beans.

    Simple, right.

    I’m playing Doom Eternal for fun at the moment. And just thinking of this abomination called “maven”, which Java uses to build shit makes me wish for all maven devs to rot in hell eternally. This piece of junk is basically undocumented. Don’t get me wrong, theres tons of written stuff, intros, tutorials, etc. about maven. It’s just after reading all of them you’re still the same code-copy-pasting monkey you were before. Once you hunted down the snippet on Stackoverflow you go on to the next blackbox.

    Examples? Sure.

    • Versions in build plugins. Maven complains, but countless examples I found don’t use any version. (A Java illness, it seems all examples have to be incomplete, otherwise it’s no fun for the developer, right?).
    • Complexity. You can configure the versions-maven-plugin to update the version numbers. To ignore alpha / beta / whatever versions you have to write a regex expression in a separate file and import that to the pom.xml. Of course you write the import statement in the configuration section of the plugin. Writing the rules in there? Naaaaah, too easy my friend. Extra file please.
    • Commands. There’s no help. There’s only “plugins”. No starting point, no idea what’s “default” and what the 1, 2, 3 steps are to get your app built. Just a bunch of horseshit you try out until your app is built. Or you think it is. (Or back to Stackoverflow, take the first example that works and go on to the next blackbox …)
    • Reposities. It seems I built my app several times correctly, then I configured some repositories, and suddenly it was built … more correctly. Don’t ask me why.

    Let’s continue with Spring. They once were (and probably still are) on the forefront of “modern”, modularized, reusable, enterprise-pattern-enabled, lightweight Java. Problem is, that’s still way too complex for any sane human being.

    Examples? Sure.

    • Configuration. I try to use Apache Camel. Seems to be a great product, all is configurable using either Spring DSL or code. Now if you want to do it with Spring, until today I invested days to find out how to read the fucking configuration from that god-damned configuration file. It’s just. Not. Possible. Sure, countless examples on the net, but that leads me to …
    • the documentation. Just some random notes:
    • The examples there are just don’t cut it and come basically without any documentation.
    • All links which sound like they could help lead to a 404 page.
    • “if you want to do X you can ‘easily’ do this using Spring XML” is a sentence I want to burn now, because … well, there’s no example, usually. You’re just being redirected to some Spring page which explains the Spring concepts in epic detail, with no connection whatsoever to the actual problem with the actual fucking library.
    • If they include a code snippet it’s always without any context. So you have the critical 3 lines, but if you want to include them into an actual application, you wonder about imports, namespaces, setup boilerplates, and countless other things every. Single. Time.
    • In summary it seems the docs are there for the pros who want to just quickly look something up they inconveniently forgot cause they already know a shit ton of shit. If you’re new to this? Yeah, go ahead, it’s easy, here’s a link to the Spring concepts.
    • Oh yeah, and it might be it’s just plainly, utterly, horribly wrong. But Java being nothing but enterprise, it’s at lease consistently wrong all the time.

    I think I managed to solve the problem just now. Unfortunately this cost me days, and only because of the most brainwashed, brainfucked eco-system I can imagine.

    (Disclaimer: I think Java has some really cool parts as well, just right now – I honestly don’t care. At all.)

  • Use autohotkey for text expansion on Windows

    Under macOS I use TextExpander, under Windows there’s the fantastic AutoHotkey. One of the few softwares I can’t live without.

    This is my default configuration:

    ; ---------- "auto reload" ----------
    
    FileGetTime ScriptStartModTime, %A_ScriptFullPath%
    SetTimer CheckReload, 1000, 0x7FFFFFFF ; ms & priority
    
    ; from here: https://stackoverflow.com/a/45488494
    CheckReload() {
        global ScriptStartModTime
        FileGetTime curModTime, %A_ScriptFullPath%
        If (curModTime <> ScriptStartModTime) {
            Loop
            {
                reload
                Sleep 300 ; ms
                MsgBox 0x2, %A_ScriptName%, Reload failed. ; 0x2 = Abort/Retry/Ignore
                IfMsgBox Abort
                    ExitApp
                IfMsgBox Ignore
                    break
            } ; loops reload on "Retry"
        }
    }
    
    
    ; ---------- actual content here ----------
    
    ; removed all my email address shortcuts ...
    
    :*:-dt::
      ; from here: https://is.gd/3u6MKQ
      Send, %A_YYYY%-%A_MM%-%A_DD%
      Return
    
    :*://ts::
      Send, %A_YYYY%%A_MM%%A_DD%_%A_Hour%%A_Min%%A_Sec%
      Return
    
  • JIRA and Python

    I really came to hating JIRA with a passion. And now I have to create about 350 tickets.

    Naturally I don’t do this by hand. But using the JIRA API is kind of … hard, there is a Python library, but usage is rather sparsely documented, and this whole thing is just annoying as hell.

    Although when you did it, it’s quite simple. Here’s an example of how to create a ticket with due date and estimate set from a CSV file:

    from pprint import pprint, pformat
    from getpass import getpass
    
    import jira
    
    
    def do_shit():
        url = read("JIRA url:")
        username = read("JIRA username:")
        password = getpass("JIRA password:")
        jira_inst = jira.JIRA(url, basic_auth=(username, password))
    
        test = {
            "project":          {"key": "TEST"},
            "issuetype":        {"name": "Task"},
    
            "labels":           ["deleteme", "whatisthis"],
    
            "summary":          "woho",
            "description":      "wohooooo",
            "duedate":          "2017-11-11",
    
            "timetracking":    {"originalEstimate": "4d"},
        }
    
        created = jira_inst.create_issues([test])
        pprint(created)
    
    
    if __name__ == "__main__":
        do_shit()
    

    So simple.

  • jq makes AWS “describe-instances” actually useful

    Just so I don’t forget 🙂

    aws ec2 describe-instances | \
      jq '.Reservations[].Instances[] | {IP: .PrivateIpAddress, ID: .InstanceId, Name: .Tags[] | select(.Key=="Name").Value}'
    
  • Ansible inventory file from Consul

    Quick self-reminder:

    curl consul.domain:8500/v1/catalog/nodes | jq '.[]|.Address' | tr -d '"'
    
  • jq stuff

    Waah. In case I *ever* need this again.

    aws ec2 describe-security-groups | \
        jq '.SecurityGroups | \
            map(select(has("Tags"))) | \
            map(select(.Tags[].Key|contains("Name"))) | \
            .[] | \
            [ .Tags , .GroupId ] | \
            [ (.[0]|map(select(.Key=="Name")))[0].Value, .[1] ] | \
            join("=") '
    

    What does it do? It makes a list

    $NAME_TAG=$GROUP_ID
    

    … for each security group which has a name tag. Yeah, right.

  • Microsoft Code and Typescript

    So being on the enterJS conference I wanted to get started with JavaScript. And TypeScript seems really promising. And once again I stumbled over the DIW pattern – Download, Install, Weird error messages.

    So, here’s my take on how to get started.

    I wanted …

    • to try node-hid to see my USB HID devices, using TypeScript, Microsoft Visual Studio Code, and Node.js.

    So here’s how to get it to work:

    $ mkdir my_project_dir
    $ cd my_project_dir
    $ brew install node            # I'm on Mac ;)
    $ npm install -g typescript    # install globally
    $ npm install node-hid         # install locally
    

    Fire up Code, and “open” the project directory “my_project_dir”.

    Press “CMD-SHIFT-P” (probably CTRL-SHIFT on non-OSX machines) and search for “Configure task runner”. Here you use this configuration:

    {
      "version": "0.1.0",
      "command": "tsc",
      "isShellCommand": true,
      "showOutput": "silent",
      "args": [],
      "problemMatcher": "$tsc"
    }
    

    Then create a new file called “test.ts”, with the following content:

    // typescript does not know "require".
    // you have to convince it it "will exist at runtime".
    // http://stackoverflow.com/a/12742371/902327
    declare function require(name: string);
    var HID = require("node-hid");
    var devices = HID.devices();
    console.log(devices);
    

    Now if you press “CMD-SHIFT-B” this should compile and create a file called “test.js”.

    I don’t know (yet) how to run it from within Code, so on the command line I can test it by doing …

    // command: node test.js
     { vendorId: 1452,
        productId: 589,
        path: 'USB_05ac_024d_fa120000',
        serialNumber: '',
        manufacturer: 'Apple Inc.',
        product: 'Apple Internal Keyboard / Trackpad',
        release: 521,
        interface: -1 },
      { vendorId: 0,
        productId: 0,
        path: '',
        serialNumber: '',
        manufacturer: '',
        product: 'Apple Mikey HID Driver',
        release: 0,
        interface: -1 },
      { vendorId: 1452,
        productId: 589,
        path: 'USB_05ac_024d_fa120000',
        serialNumber: '',
        manufacturer: 'Apple Inc.',
        product: 'Apple Internal Keyboard / Trackpad',
        release: 521,
        interface: -1 },
      { vendorId: 1452,
        productId: 589,
        path: 'USB_05ac_024d_fa120000',
        serialNumber: '',
        manufacturer: 'Apple Inc.',
        product: 'Apple Internal Keyboard / Trackpad',
        release: 521,
        interface: -1 },
      { vendorId: 1452,
        productId: 589,
        path: 'USB_05ac_024d_fa120000',
        serialNumber: '',
        manufacturer: 'Apple Inc.',
        product: 'Apple Internal Keyboard / Trackpad',
        release: 521,
        interface: -1 } ]
    

    Article Sources:

    Microsoft Visual Studio Help Stackoverflow

  • Shared clipboard for Arch Linux as VMWare guest

    … aaaand I wanted to have a shared clipboard. It’s again all in the wiki, but again a bit distributed. So here we go.

    First: Install open-vm-tools and gtkmm, then add some modules to system bootup

    • “sudo pacman -S open-vm-tools gtkmm“
    • “sudo vim /etc/mkinitcpio.conf”
    • Under “MODULES=…” add the following: “vmxnet3 vmw_vmci vmw_pvscsi vmwballoon” (You probably don’t need most of them, but this is the config which worked for me. I didn’t try to remove them one-by-one to see which ones are _actually needed)
    • “sudo mkinitcpio -p linux”
    • reboot

    Second, make sure “vmware-user-suid-wrapper” is stared on login:

    • echo vmware-user-suid-wrapper > ~/.xinitrc
    • Logout and log in (or reboot)

    Done.

  • Sublime Text: Keyboard Shortcut for setting Tab Width

    Schwer zu finden … Wer schnell über das Keyboard die Tab Width verändern will, der tue das so:

    {
      "keys": ["super+k", "super+2"],
      "command": "set_setting",
      "args": {
        "setting": "tab_size",
        "value": 2
      }
    }
    

    (gefunden hier: http://is.gd/Pz9zE0)