Skip to content

Instantly share code, notes, and snippets.

@dogukancagatay
dogukancagatay / trigger-timedatectl-sync.py
Created March 14, 2024 08:27
Python script to force timedatectl NTP time sync
import socket
import struct
import subprocess
import time
REF_TIME_1970 = 2208988800 # Reference time
def get_ntp_time(addr="0.de.pool.ntp.org") -> int | None:
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@dogukancagatay
dogukancagatay / macos_vm_parallels.md
Created February 8, 2024 14:44
Create MacOS VM on Parallels #macos #parallels #vm

Create MacOS VM on Parallels

Download ipsw image for the desired version of the MacOS. Use the following site to get the link.

wget 'https://updates.cdn-apple.com/2024WinterFCS/fullrestores/042-78241/B45074EB-2891-4C05-BCA4-7463F3AC0982/UniversalMac_14.3_23D56_Restore.ipsw'
@dogukancagatay
dogukancagatay / sdkman-cheatsheet.md
Last active February 6, 2024 09:36
sdkman cheatsheet #sdkman #java

sdkman Cheatsheet

List supported software

sdk list

List Java versions

# sdk list <
@dogukancagatay
dogukancagatay / mypy_compiled.sh
Last active March 15, 2024 13:47
Install compiled version of Mypy #python #mypy
#!/usr/bin/env bash
# Check whether your mypy version compiled: `mypy --version`
# Mypy works a lot faster when using the compiled version
## Usage:
## curl -fL 'https://gist.githubusercontent.com/dogukancagatay/99df8636b0ca9d5a59f40b50f4a70970/raw/mypy_compiled.sh' | bash
MYPY_VERSION="${1:-1.9.0}"
curl -fL -o /tmp/${MYPY_VERSION}.tar.gz "https://github.com/python/mypy/archive/refs/tags/${MYPY_VERSION}.tar.gz"
@dogukancagatay
dogukancagatay / lima_fedora35.yaml
Last active March 30, 2023 15:12
Lima Fedora configuration files derived from default.yaml with fallback image urls
# ===================================================================== #
# BASIC CONFIGURATION (FEDORA 37)
# ===================================================================== #
# Default values in this YAML file are specified by `null` instead of Lima's "builtin default" values,
# so they can be overridden by the $LIMA_HOME/_config/default.yaml mechanism documented at the end of this file.
# VM type: "qemu" or "vz" (on macOS 13 and later).
# The vmType can be specified only on creating the instance.
# The vmType of existing instances cannot be changed.
#!/bin/bash
# Name: kvm.sh
# Purpose : Control remote server/laptop/desktop using KVM and VNC client
# Author: nixCraft {https://www.cyberciti.biz/} under GPL v3.x
# ----------------------------------------------------------------------
xIP='192.168.2.88'
xPASSWORD='PasssordHere'
xVNC_PWD='In9t8el@' # random but must be 8 charter long
xVNC_PORT='5900'
wsman put http://intel.com/wbem/wscim/1/ips-schema/1/IPS_KVMRedirectionSettingData -h $xIP -P 16992 -u admin -p ${xPASSWORD} -k RFBPassword=${xVNC_PWD}
@dogukancagatay
dogukancagatay / generate-gpg-keys.sh
Created February 16, 2022 19:42
Generate GPG keys
#!/usr/bin/env bash
_GPG_KEY_NAME="apt-service"
## Clean residual files
rm -rf $_GPG_KEY_NAME.txt $_GPG_KEY_NAME*.gpg
## Create a temporary GPG home
export GNUPGHOME="$(mktemp -d)"
@dogukancagatay
dogukancagatay / .insync.ignore
Created January 3, 2022 17:13
Insync ignore file list
$RECYCLE.BIN
$Recycle.Bin
System Volume Information
ehthumbs.db
desktop.ini
Thumbs.db
lost+found
.DocumentRevisions-V100
.TemporaryItems
.fseventsd
@dogukancagatay
dogukancagatay / send_test_email.py
Created April 7, 2021 15:43
Send test e-mail with Python smtplib
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
s = smtplib.SMTP(host="localhost", port=25)
# s.starttls() # Enable if your mail server uses TLS
# s.login("user.name@example.local", "mysupersecretpassword") # Enable if using user authentication
@dogukancagatay
dogukancagatay / set-git-config-profile.sh
Last active March 21, 2021 15:27
Conditionally change your git-config profile based on directory using includeIf option.
#!/usr/bin/env bash
PROFILE_NAME="$1"
CONFIG_FILE="$HOME/.gitconfig-$PROFILE_NAME"
function show_usage() {
echo "Usage:"
echo -e "\tset-git-config-profile.sh <profile-name> : Sets the profile for current directory"
echo -e "\tset-git-config-profile.sh -r : Unsets any profile for current directory"
}