Walchsee. Kössen
Two more videos are after the break:
- Kössen
- Ruhpolding, Unternberg
Two more videos are after the break:
It turned out that the newest versions (at least 5+) of webpack support Typescript out of the box. So the algorithm is next:
tsconfig.json at the root level. Content:{ "compilerOptions": { "module": "CommonJS", "target": "ES5", "esModuleInterop": true, "checkJs": false, "strict": true, } }
.js files to *.tsrequire, use import.webpack package has typings out of the box.
Configuration & RuleSetRuledevServer write this: interface Configuration extends WebpackConfiguration { devServer?: WebpackDevServerConfiguration; }
*.d.ts filedeclare module 'postcss-assets' { export default function postcssAssets(opts: { basePath: string; relative: boolean; }): unknown; }
webpack.config.ts file is placed at the root level. I mean exactly at the same spot where node_modules is. Otherwise, you won’t be able to build it. No compilerOptions helped me. Put this content:
[Unit] Description={name} [Service] Type=simple User={user} ExecStart=/usr/bin/node {full-path-to-script}.js [Install] WantedBy=multi-user.target
… somewhere as {name}.service, where:
{name} is the name of the service{user} is the name of the user to run the script (optional)… then:
this sudo ln -s /{full_path}/{name}.service /lib/systemd/system/{name}.service sudo systemctl daemon-reloadsudo systemctl enable {name}.servicesudo systemctl start {name}How does it work?
WantedBy section).ExecStart command. Important: we specify the full path to nodeSystemD remembers the PID of the new process and considers the service is ongoing until the process is died.systemctrl start {name} won’t do anything if the previous process is alive.Type=Simple
One more video (with my launches) is after the break
Imagine that you want to add support of some keybinds in your web application. Let it be Ctrl+L for liking\unliking something. What kind of issues can you face in such a scenario?
At first look at Ctrl. Probably on MacOS you’d like to replace it with CMD. You can check it by event.metaKey.
Probably you wouldn’t like to consider Ctrl+Alt+S as Ctrl+S. So don’t forget to handle this case.
Not every language that uses the Latin alphabet has the L button at the same position as in a typical English keyboard layout. You need to decide what is more important to you ― a real key position on a keyboard or a letter upon of it. I’d guess that the 2nd case is preferable for most applications.
To get a real key position you can use which, code, codeKey properties. To get a letter on the key use key property.
What’s about Greek or Russian alphabets? Or any other possible alphabets? Or not even alphabets? There’re different strategies. And one of them is to use a key from a typical English keyboard layout. So it leads us again to code and codeKey properties.
const getEventKeyBind = event => { const keybind = []; if (event.metaKey) keybind.push('cmd'); if (event.ctrlKey) keybind.push('ctrl'); if (event.shiftKey) keybind.push('shift'); if (event.altKey) keybind.push('alt'); if (event.key === ' ') keybind.push('space'); else { const key = event.key.toLowerCase(); if (key.length !== 1 || key.match(/^[a-z]$/)) { // latin key or a special key keybind.push(key); } else { // extra-latin or non-latin key const [, enSymbol] = event.code.match(/^Key(\w)$/) || []; keybind.push(enSymbol ? enSymbol.toLowerCase() : key); } } return keybind.join('+'); };