Skip to content

Instantly share code, notes, and snippets.

View jsynowiec's full-sized avatar

Jakub Synowiec jsynowiec

View GitHub Profile
@jsynowiec
jsynowiec / gen_ssh_key.sh
Created January 18, 2023 12:11
The following command will create a new SSH key using ED25519 with an auto-generated comment and unique file name.
# Change the service variable to uniquely identify a service or area the key is intended for.
service="github" \
now=$(date +'%Y%m%d') \
name="$(whoami)@$(hostname -s | tr +'[:upper:]' +'[:lower:]')" \
sh -c 'ssh-keygen -t ed25519 -f $HOME/.ssh/id_ed25519_$name_$service -C "$name-$service-$now"'
@jsynowiec
jsynowiec / update-oem-vmware.sh
Created April 30, 2021 13:53 — forked from neilmayhew/update-oem-vmware.sh
Update a Flatcar installation on VMWare to use the latest OEM content
#!/usr/bin/env bash
# Update a Flatcar installation on VMWare to use the latest OEM content
#
# Copyright 2020, Neil Mayhew <neil@kerith.ca>
# LICENSE: MIT
set -ex
shopt -s extglob nullglob
@jsynowiec
jsynowiec / GitHub Dark.icls
Last active September 19, 2023 00:37
GitHub (Primer) Visual Studio Code syntax color schemes for JetBrains IDEs like IntelliJ, PyCharm, WebStorm, PhpStorm, GoLand, CLion, RubyMine or AppCode
<scheme name="GitHub Dark" version="142" parent_scheme="Darcula">
<metaInfo>
<property name="created">2020-07-20T12:05:56</property>
<property name="ide">Python</property>
<property name="ideVersion">2020.1.3.0.0</property>
<property name="modified">2020-07-20T12:05:58</property>
<property name="originalScheme">Github Dark</property>
</metaInfo>
<colors>
<option name="CARET_COLOR" value="c8e1ff" />
@jsynowiec
jsynowiec / GitHub Dark.itermcolors
Created May 26, 2020 13:02
Take on primer/github-vscode-theme dark and light themes as iTerm2 color schemes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.18039216101169586</real>
@jsynowiec
jsynowiec / sync_theme.py
Last active March 5, 2024 06:06
Sync iTerm2 color preset with macOS dark or light theme on start and when theme changes.
#!/usr/bin/env python3
"""Set iTerm2 color preset according to macOS theme.
Requires iTerm2 version 3.3 or newer.
Save as ~/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch/sync_theme.py and
enable under scripts menu in iTerm2.
"""
@jsynowiec
jsynowiec / jest.config.json
Last active April 21, 2021 08:37
[Jest config for debugging TypeScript tests in Visual Studio Code] #vscode #jest #typescript
{
"testEnvironment": "node",
"transform": {
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": [
"ts",
"js",
"json",
"node"
@jsynowiec
jsynowiec / yarn-or-npmi.js
Last active April 28, 2019 10:50
[yarn with npm fallback] Try to install dependencies using yarn or fall back to npm if yarn is not available #nodejs #yarn #npm
const os = require('os');
const exec = require('child_process').exec;
switch (os.platform()) {
case 'win32':
exec('yarn --version', (err, stdout, stderr) => {
if (err) {
exec('npm install');
return;
} else {
@jsynowiec
jsynowiec / server.js
Last active October 10, 2016 12:02
Detect if a module has been run directly from Node.js or imported, read more: https://nodejs.org/api/modules.html#modules_accessing_the_main_module
const dgram = require('dgram');
let server = dgram.createSocket('udp4');
function bind(socket, port = 8088, address = '0.0.0.0', callback = () => {}) {
socket.bind(port, address, callback);
}
// Bind server only if module was run directly, eg. node server.js
if (require.main === module) {
@jsynowiec
jsynowiec / thinkpad-dock
Last active October 4, 2021 07:21
[Thinkpad Series 3 docking station scripts] Thinkpad "docking scripts" for Series 3 docking station enabling or disabling both external displays on acpi events (https://www.kernel.org/doc/Documentation/laptops/thinkpad-acpi.txt). Only one pair of events should be used - check which ones (IBM/LENOVO/HKEY) acpid daemon receives. #thinkpad #linux #…
# /etc/acpi/events/thinkpad-dock
# This is called when the Thinkpad docks in a series 3 docking station
event=ibm/hotkey HKEY 00000080 00004010
action=/etc/acpi/thinkpad-dock.sh