Skip to content

Instantly share code, notes, and snippets.

View git-spli-file.sh
#!/bin/sh
if [[ $# -ne 2 ]] ; then
echo "Usage: git-split.sh original copy"
exit 0
fi
git mv $1 $2
git commit -n -m "Split history $1 to $2"
REV=`git rev-parse HEAD`
@skhalymon
skhalymon / install-app-for-android-auto.sh
Created May 20, 2021
Install apps for Android Auto without Root from Mac Os and Linux
View install-app-for-android-auto.sh
#!/bin/bash
adb push $1 /data/local/tmp/app.apk
adb shell pm install -i "com.android.vendoring" -r /data/local/tmp/app.apk
adb shell rm /data/local/tmp/app.apk
View install-and-run-srt-server.sh
#!/usr/bin/env bash
sudo apt update
sudo apt install -y tclsh pkg-config cmake libssl-dev build-essential git tmux
git clone --depth 1 --branch v1.4.2 https://github.com/Haivision/srt.git
cd srt
./configure --prefix=/usr
make
sudo make install
cd ..
@skhalymon
skhalymon / enum_deprecation.py
Last active Apr 24, 2020
Old value `EDGE` would be marked as deprecated by IDE and deprecation message would be printed each `BrowserType.EDGE` call
View enum_deprecation.py
class DynamicEnumGetter(object):
def __init__(self, fget=None):
self.fget = fget
def __get__(self, instance, ownerclass=None):
return self.fget(ownerclass)
class BrowserType(Enum):
EDGE_LEGACY = "edgelegacy"
EDGE_CHROMIUM = "edgechromium"
EDGE_CHROMIUM_ONE_VERSION_BACK = "edgechromium-1"
View frame2.html
<!DOCTYPE html>
<html>
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cross SDK test</title>
<style>
div {
font-family: "Arial", sans-serif;
@skhalymon
skhalymon / proxy_obj.py
Created Mar 5, 2020
Adds to decorated class __getter__ and __setter__ methods that allow to access attributes from proxy_object in the parent class
View proxy_obj.py
import inspect
def proxy_to(proxy_obj_name, fields):
# type: (Text, List[Text]) -> Callable
"""
Adds to decorated class __getter__ and __setter__ methods that allow to access
attributes from proxy_object in the parent class
:param proxy_obj_name: The name of the proxy object that has decorated class.
View docker-compose.override.yml
version: '2.2'
services:
web:
volumes:
- /mnt/HC_Volume_4511185:/var/azuracast/stations
stations:
volumes:
View css_selector_from_by_value.py
def css_selector_from_(by, value):
if by == By.ID:
value = "#%s" % value
elif by == By.CLASS_NAME:
value = ".%s" % value
elif by == By.NAME:
value = '[name="%s"]' % value
elif by in [By.XPATH, By.CSS_SELECTOR, By.TAG_NAME]:
value = value
else:
View get_ip.py
import requests
def get_public_ip():
try:
r = requests.get('http://ip.o11.net', timeout=(2.0, 2.0))
if r.status_code == 200:
return r.text.rstrip()
except requests.RequestException:
warnings.warn(f'Cannot fetch public ip')
return None