Skip to content

Instantly share code, notes, and snippets.

View alexander-malafeev's full-sized avatar

Alexander Malafeev alexander-malafeev

  • Zürich, Switzerland
View GitHub Profile
@alexander-malafeev
alexander-malafeev / ideapad_battery_conservation
Created February 19, 2020 20:51
Script to control battery conservation mode on Lenovo Yoga S940 in Linux. Should work on all ideapad laptops.
#!/bin/bash
# script is based on answers at https://askubuntu.com/questions/1038471/problem-with-lenovo-battery-threshold
# and relies on the module ideapad-laptop
# arguments are status, on and off are self-explanatory
if [ "$1" == "status" ]
then
cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
elif [ "$1" == "on" ]
then
sudo echo 1 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
@alexander-malafeev
alexander-malafeev / remove_background.py
Created April 22, 2018 17:40
# remove-background Often we need to remove monotonous background from the image. However often color of pixels is not exactly uniform due to the compression artifacts. It is expecially critical arund the object. Thus the simple fill won't work. This script takes the color of the top left pixel as a reference one and performs a fill with the whi…
from scipy import misc
import glob
import numpy as np
import sys
#print len(sys.argv)
if len(sys.argv)<3:
print "not enough arguments"
print "try python remove_background.py infile outfile [threshold = 10]"
else: