966Combining JSON files in Python

Quick python script to combine several JSON files into one. File names are dict keys in the JSON output.

import os
import json

entries = os.listdir(os.getcwd())

animationFiles = [
  'aaa',
  'bbb',
  'ccc'
]

output = {}

for name in animationFiles:
  with open(name + '.json') as f:
    output[name] = json.loads(f.read())

outputFile = open('output.json', 'w')
outputFile.write( json.dumps(output) )

print('Done')

964Gettting HTML Content from index.html into Vue

Vue index.html:

  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
    <div id="modalContent" style="display:none">
      <div id="modal1">
        Hello Modal Content Hello Modal Content
      </div>
    </div>
  </body>

Why add another hidden div to index.html? To be able to edit/add content without rebuilding and running npm run build.

In Vue:

  document.getElementById('modal1').innerHTML

Actually basic JS, nothing special to Vue.

963General JS Variables in Vue

Accesses JS from outside Vue:

index.html

...
<script>
  var test = "test";
</script>
...

In Vue:

  window.test

Obvious, but nevertheless

962Zooming and Panning in D3 with Bounds

Standard d3.zoom, pans to infinity:

this.zoom = d3.zoom()
  .scaleExtent([1/2, 100])
  .on("zoom", () => {
    g.attr("transform", d3.event.transform)
  })

Restrict pan to visible area, adjust padding (p):

this.zoom = d3.zoom()
  .scaleExtent([1/2, 100])
  .on("zoom", () => {
    var p = 0.95, e = d3.event.transform, w = this.width, h = this.height
    e.x = Math.min(Math.max(e.x, -w * e.k * p), w * p)
    e.y = Math.min(Math.max(e.y, -h * e.k * p), h * p)
    g.attr("transform", e)
  })

Vue 2.x, D3 5.0

961A Relative Path for Vue

Create a new file, call it vue.config.js

Add:

module.exports = {
  publicPath: ''
}

This overwriting the default value of '/'.

Source: https://cli.vuejs.org/config/#publicpath

959Making a Bootable Installer for OSX

Straight from the Apple Support page: How to create a bootable installer for macOS https://support.apple.com/en-us/HT201372 High Sierra Page https://support.apple.com/en-us/HT208969 High Sierra App Store Link (hidden from standard Search) https://itunes.apple.com/us/app/macos-high-sierra/id1246284741?ls=1&mt=12

953Changing Languages in WordPress

Install additional language: Change user language:

957Htaccess and White-listing IPs

AuthUserFile /path/to/.htpasswd
AuthName "Restricted Access"
AuthType Basic
Require valid-user
Satisfy Any
Deny from All
Allow from 123.456.78.90

Allow IP ranges:

Allow from 123.456.78
Allow from 123.456

951Making a Bootable USB Stick – for Linux – in OSX

The Manjaro Wiki suggests to make a bootable USB Stick like that:

sudo dd bs=4M if=/path/to/manjaro.iso of=/dev/sd[drive letter] status=progress oflag=sync

While this might work on Linux, it does not work with dd on OSX/Darwin. Here are the error messages:

dd: bs: illegal numeric value
bs does not understand M
multiply manually, 4M -> 4 1024 1024 -> 4194304

sudo dd bs=4194304 if=/path/to.iso of=/dev/diskNr status=progress oflag=sync

dd: unknown operand status
dd on OSX does not understand the status flag
remove status flag

sudo dd bs=4194304 if=/path/to.iso of=/dev/diskNr oflag=sync

dd: unknown operand oflag
dd on OSX does not understand the oflag oflag
remove oflag flag

sudo dd bs=4194304 if=/path/to.iso of=/dev/diskNr

dd: /dev/disk4: Resource busy
Unmount disk before use, either via umount or in Disk Utility

And here we have it:

sudo dd bs=4194304 if=/path/to.iso of=/dev/diskNr

950SSH, Keys and Cyberduck

Environment: OSX 10.15.2

Understanding ~/.ssh/config

Host test.trembl.org              # Hostname
  User trembl                     # Username
  IdentityFile ~/.ssh/trembl_rsa  # Path to Key

Before config entry:

ssh -i ~/.ssh/trembl_rsa trembl@test.trembl.org

After config entry:

ssh trembl@test.trembl.org

.ssh/config looks up the corresponding IdentityFile and applies the matching IdentityFile for user & host

Keychain Access, SSH & Cyberduck

Adding key to the ssh agent:

ssh-add -K ~/.ssh/trembl_rsa

Check, if the key is present?

ssh-add -l 

Response:

2048 SHA256:abcdefghijk trembl@Fischer.local (RSA)

This does not add the key to the Keychain Access App. Does it survive a restart, or will it only be in RAM?

Answer?

Login in via Cyberduck adds Passphrase to the Keychain Access App. Is this persistent?