scorp's spot
this is my spot in Internet
16 March 2018
Capture audio input + output with pulseaudio
Solution is courtesy to this youtube video and for own use I made a script out of it.
17 November 2016
Java dynamic proxy adding interface implementation (introducing an interface) to an object with Spring
While knowing the keyword makes task way easier I will still share the recipe.
What we need to do
To wrap an object instance with a AOP proxy adding an interface implementation to it.Code example is available here http://www.java2s.com/Code/Java/Spring/SpringAspectIntroductionExample.htm
03 May 2016
Make 'Open class' dialogue of IntelliJ IDEA behave under Awesome WM
Recently it was demystified for me with the help of Jetbrains developers and support and the community. There appeared to be a long-hanging issue regarding this weird behaviour IDEA-65043. And once it gained some more attention at least exact conditions triggering the issue were discovered.
The problem was caused by sloppy focus (AKA focus-follows-mouse) which is the default in some environments among which Awesome WM is. Now it can easily be solved!
I'm using default configuration of Awesome WM 3.5.9 as a base (which can be found in /etc/xdg/awesome/rc.lua).
Somewhere in the bottom there is a snippet we're looking for
-- {{{ Signals -- Signal function to execute when a new client appears. client.connect_signal("manage", function (c, startup) -- Enable sloppy focus c:connect_signal("mouse::enter", function(c) if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier and awful.client.focus.filter(c) then client.focus = c end end)This is the sloppy focus implementation. Need to introduce a flag to switch it on\off. Change it to:
-- {{{ Signals -- Signal function to execute when a new client appears. sloppyFocus = true client.connect_signal("manage", function (c, startup) -- Enable sloppy focus c:connect_signal("mouse::enter", function(c) if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier and awful.client.focus.filter(c) and sloppyFocus then client.focus = c end end)
Now we have a switch, and we need to turn it off while we're working with IDEA (or WebStorm, etc) and the turn back on when we're off it. Find awfule.rules section in your config (for me it's right above the sloppy focus implementation snippet) and add a new rule:
{ rule = { class = "jetbrains-%w+" }, callback = function(c) c:connect_signal("focus", function (client) sloppyFocus = false end) c:connect_signal("unfocus", function (client) sloppyFocus = true end) end },This matches any window of virtually any Jetbrains' product and switches sloppy focus off while it's focused, then switches sloppy back on when focus leaves IDE.
Thanks awesome Awesome developers for allowing patterns in rule preconditions! :-)
22 October 2015
Pulseaudio server in Docker container
In short here it is:
Now everything one by one:
- docker run --rm -ti - run non-persistent docker and prepare it as interactive (shell) run
- --device=.... make local sound devices available in container. This feature is quite new in docker, so make sure you have recent version (mine is 1.8)
- -p 4713:4713 set up port forwarding between host and container to make pulse server available to clients
- rpi-deb-pulse is my docker image built from armbuild/debian by running system upgrade and install pulseaudio
- /bin/bash -c "..." is command to run inside container, more on this below
- groupadd --gid $(...) alsadev create a group inside container named alsadev and having same id as group of /dev/snd/controlC0 device. We need this to allow pulse to access native alsa devices.
- $(ls -l /dev/snd/controlC0 | cut -d' ' -f4 | xargs getent group | cut -d: -f3) this subshell is executed on host, not in container and prints group id of /dev/snd/controlC0
- gpasswd -a pulse alsadev adds user pulse to our new group alsadev
- pulseaudio ... run pulseaudio
- -L 'module-alsa-sink device=hw:0,0' explicitly load alsa sink and specify which output to use
- -L 'module-native-protocol-tcp auth-ip-acl=10.2.0.0/24' load tcp protocol listener and (optionally) configure ip-acl to only accept connections from given subnet
- pactl load-module module-tunnel-sink server=10.2.0.1
- in pavucontrol on Playback tab select desired sink for a stream
- list of devices may be replaced with another subshell to not specify each dev manually
- add systemd unit to start container automatically
- tune pulseaudio since sound over tcp tunnel is worse then playing locally
09 March 2015
Seesu.me, dwb & vk.com
The story
seesu.me is an awesome online media player or radio or whatever you call it. Just give it try.dwb is a minimalistic vim-imsnpired browser.
And vk.com is popular (at least in xUSSR countries) social network.
What brings them all here is that there is large music collection available on vk.com which can be very nicely listened to with seesu.me. But me problem was that vk login button wasn't working in dwb browser.
The solution
In short i needed to do the following:- open dev console (dwb is based in webkit, so there is on) to find the login button
- check if clicking on it programatically would work
- if yes, all done - i'll login to vk, login will be remembered and nothing to worry about
After that dev console popped up on :wi command, but unfortunately each time it shows up it crashes the whole browser.
I had to pick firefox to check if triggering click programmatically would do the trick and it really did. Invoking $('.sign-in-to-vk').click() in dev console was at least triggering popup blocker and then i was able to reach the popup (BTW popup blocker was veeery important here).
Back to dwb i needed a way to execute arbitrary JS on a page which was quickly and easily found in already opened man page. So on seesu page i typed :js $('.sign-in-to-vk').click() and nothing happened again. Here i remembered about popup blocker and (quickly again) found and option javascript-can-open-windows-automatically which was set to true with ss javascript-can-open-windows-automatically true
After that repeating JS snipped worked like a charm.