Skip to content

Instantly share code, notes, and snippets.

@itaiin
itaiin / switch_headset_profile.sh
Last active September 19, 2024 06:53
switch_headset_profile.sh
#!/bin/bash
#
# Changes headset profile between A2DP and HFP
#
set -x
A2DP_PROFILE=a2dp_sink
HFP_PROFILE=handsfree_head_unit
HEADSET_CARD=<card name you can get by doing pactl list>
#!/usr/bin/env python3
import argparse
from datetime import datetime
from pathlib import Path
import exif
def rename_by_exif(path):
meta = exif.Image(path)
@itaiin
itaiin / git_branch_in_bash_snippet.sh
Last active January 20, 2025 15:00
bash git branch snippet
# Snippet from https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt/730758
# Add git branch if its present to PS1
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
@itaiin
itaiin / profiles.json
Last active December 31, 2019 07:41
Personal Microsoft Terminal preferences
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
"profiles":
@itaiin
itaiin / LICENSE
Created October 28, 2019 09:40 — forked from noelbundick/LICENSE
Exclude WSL installations from Windows Defender realtime protection
MIT License
Copyright (c) 2018 Noel Bundick
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@itaiin
itaiin / python_logging.c
Created May 5, 2019 08:42 — forked from hensing/python_logging.c
Python: Use 'logging' module from C extension
#include <Python.h>
/***********************************************************/
/* define logging function and logtypes for python.logging */
/* by H.Dickten 2014 */
/***********************************************************/
enum logtypes {info, warning, error, debug};
static void log_msg(int type, char *msg)
{
@itaiin
itaiin / install_custom_python_in_conda.sh
Last active April 28, 2019 08:04 — forked from bombs-kim/install_custom_python_in_conda.sh
How to install a custom python binary(ex. python-dbg) in your conda environment.
# This instruction is for Unix-like OS users.
# I refered to the following guide when I wrote it.
# https://conda.io/docs/user-guide/tasks/build-packages/recipe.html
# Activate an environment if needed
conda activate myenv
# Install conda-build if you haven't. Ironically, installing conda-build
# includes installing python. This python will be effectively replaced with
# your new python binary so don't worry.
minikube stop; minikube delete &&
docker stop $(docker ps -aq) &&
rm -rf ~/.kube ~/.minikube &&
sudo rm -rf /usr/local/bin/localkube /usr/local/bin/minikube &&
launchctl stop '*kubelet*.mount' &&
launchctl stop localkube.service &&
launchctl disable localkube.service &&
sudo rm -rf /etc/kubernetes/ &&
docker system prune -af --volumes
@itaiin
itaiin / extract_attachments.py
Last active February 18, 2019 14:05 — forked from umrashrf/extract_attachments.py
Download emails from GMail API and extract files from each email using Python and GYB
"""
A utility to extract email attachments
"""
import os
import sys
import email
import argparse
#!/usr/bin/env python3
"""
Run a cli command, and show its io statistics, like so:
$ processio.py cat input.txt
Note that you would usually have to run this with sudo, since in most systems
the ownership of a process /proc after the subprocess dies transfers to root
"""
import sys