Skip to content

Instantly share code, notes, and snippets.

View fermino's full-sized avatar

Fermín Olaiz fermino

View GitHub Profile
@lamperez
lamperez / cs35l41_spi.md
Last active May 16, 2024 10:20
CS35L41 amplifiers in an ASUS Zenbook on linux

Asus Zenbook UX3402 speakers on Linux

Important

THIS IS NOW OBSOLETE WITH KERNEL VERSIONS ≥ 6.7.0

A recent announcement in the kernel mail list by Cirrus developers will solve the problem described here. Therefore, the proposed solutions will be soon obsolete. See this comment (thanks, @flukejones, for the tip).

I got the speakers working on my Asus Zenbook 14 OLED UX3402, the one with Intel CPU and the two CS35L41 audio amplifiers connected over SPI (not the UM3402YA, with AMD and I²C). The amplifiers are supported by the snd_hda_scodec_cs35l41 module in recent kernel versions, but they require some model-specific configuration paramaters, that should be provided by

@lamperez
lamperez / custom_acpi_tables.md
Last active May 5, 2024 22:58
Load custom ACPI tables
@venam
venam / pw-setvol.sh
Last active May 14, 2024 06:11
Set PipeWire volume natively on the default sink
#! /bin/sh
# the metadata only contains the name of the default sink
default_sink_name=$(pw-metadata 0 'default.audio.sink' | grep 'value' | sed "s/.* value:'//;s/' type:.*$//;" | jq .name)
default_sink_id=$(pw-dump Node Device | jq '.[].info.props|select(."node.name" == '" $default_sink_name "') | ."object.id"')
current_volume=$(pw-cli enum-params "$default_sink_id" 'Props' | grep -A 2 'Spa:Pod:Object:Param:Props:channelVolumes' | awk '/Float / {gsub(/.*Float\s/," "); print $1^(1/3) }')
change="${1:-0.1}" # defaults to increment of 0.1
new_volume=$(echo "$current_volume $change" | awk '{printf "%f", $1 + $2}')
# we need to reconvert to cubic root
#new_volume_cube=$(echo "$new_volume" | awk '{ print $1^3 }')
@GenevieveBuckley
GenevieveBuckley / test_monkeypatch.py
Last active December 12, 2023 18:57
Monkeypatching user input with pytest
from io import StringIO
def double():
x = input("Enter an integer: ")
return int(x) * 2
def adding():
x = float(input('Enter the first number'))
@bzub
bzub / 20180819-crostini_sommelier_fix.md
Last active January 24, 2024 12:15
Fix Crostini Wayland/X (sommelier) service

If you can't get X11 or Wayland GUI Linux apps to start anymore on Chrome OS, try the following.

In the Terminal app, this will show the status of your systemd user services/units:

systemctl --user

If sommelier@0.service and sommelier-x@0.service show a failed status, the following worked for me:

sudo ln -s /opt/google/cros-containers/bin/sommelier.elf /usr/bin/
@tokoiwesley
tokoiwesley / Install PHP 7.1 on Debian Stretch
Last active April 24, 2024 06:09
How To Install Php 7.1 On Debian
# Add Repository to your system (ondrej/php PPA)
sudo apt install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
# Install PHP 7.1
sudo apt install php7.1
@joseluisq
joseluisq / README.md
Last active May 15, 2024 19:12
Install PHP 7 Xdebug in Arch Linux

Install PHP 7 Xdebug in Arch Linux

"Normally", these instructions should be also valid (in similar way) for other Linux distros.

1.- Install Xdebug using pacman:

sudo pacman -Sy xdebug

Recovering deleted files in Ubuntu with ext4 filesystem

Recently, I deleted some files by mistake in a Ubuntu machine with an ext4 fs. These notes document the steps I took to get them back.

Important

  • this procedure assumes that the partition that contained the deleted files is different from the root partition, as that was the scenario with which I had to deal (deleted files were in my home dir). The procedure needs that the partition that contained the files is unmounted, so if the deleted files were in the root partition, the process would be a bit different (e.g. storing the fs journal in a USB stick, using a live CD/USB to boot and issue the commands, etc.)
  • if something is not clear, you need more information, etc. check the sources below

With that out the way, let's begin.

@alekswn
alekswn / adb_rotate.sh
Created January 22, 2016 23:41
Android: screen rotation from ADB
#!/bin/sh
if [ -z $1 ]
then
echo "Usage: $0 { p | l | a }. p - portrait, l - landscape, a - auto"
elif [[ $1 == a* ]]
then
echo "Turning on automatic rotation"
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:1
else
@ha7ilm
ha7ilm / openwebrx-quick-setup.sh
Last active February 3, 2022 22:13
Setting up OpenWebRX on Ubuntu 14.04 LTS
#Install dependencies
sudo apt-get install build-essential git libfftw3-dev cmake libusb-1.0-0-dev
#Fetch and build rtl-sdr, skip if already done (subdirectories will be created under the current directory).
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make