Skip to content

Instantly share code, notes, and snippets.

View nwg-piotr's full-sized avatar
🏠
~/, sweet ~/

Piotr Miller nwg-piotr

🏠
~/, sweet ~/
View GitHub Profile
@nwg-piotr
nwg-piotr / au.sh
Last active May 31, 2018 12:34
This is to add Arch Linux updates notification to your tint2 panel. Download the bash scipt and icon from https://drive.google.com/open?id=1aW7C23aUQSkcfP5RRh4hC5SEAlta26-T and unpack to your home folder. Finally add the tint2rc Executor to your ~/.config/tint2/tint2rc file. Replace `xfce4-terminal` with your favorite terminal name.
#!/bin/bash
# How to modify to use various AUR helpers:
# EITHER check regular repos, then AUR with trizen:
upd=$(/bin/sh -c "/usr/bin/checkupdates && /usr/bin/trizen -Qqu -a")
# or with yaourt:
#upd=$(/bin/sh -c "(/usr/bin/checkupdates; /usr/bin/yaourt -Qu -a | cut -c 5-) | sort -u -t' ' -k1,1")
# or pacaur:
#upd=$(/bin/sh -c "/usr/bin/checkupdates && /usr/bin/pacaur -Qqu -a")
# or aurman:
#upd=$(/bin/sh -c "/usr/bin/checkupdates && /usr/bin/aurman -Qqu")
@nwg-piotr
nwg-piotr / obhud-keybindings-rc.xml
Last active June 11, 2018 22:32
Insert this xml into the <keyboard></keyboard> section of your rc.xml file.
<keybind key="XF86MonBrightnessDown">
<action name="Execute">
<command>obhud --brightness down</command>
</action>
</keybind>
<keybind key="XF86MonBrightnessUp">
<action name="Execute">
<command>obhud --brightness up</command>
</action>
</keybind>
@nwg-piotr
nwg-piotr / nsort.py
Last active May 7, 2019 07:58
Python script to sorts the `names.txt` file containing lines like `Name Surname` alphabetically by Surname and write the result to the `names_sorted.txt` file.
#!/usr/bin/env python
# _*_ coding: utf-8 _*_
"""
This script sorts the `names.txt` file containing lines like `Name Surname` alphabetically by Surname
and writes result to the `names_sorted.txt` file.
"""
import sys
@nwg-piotr
nwg-piotr / main.py
Last active January 16, 2020 01:21
This snippet uses i3ipc python module to print dimensions of just focused container
#!/usr/bin/env python3
from i3ipc import Connection, Event
i3 = Connection()
def print_dimensions(i3, e):
try:
con = i3.get_tree().find_focused()
[ 3.634] (--) Log file renamed from "/var/log/Xorg.pid-521.log" to "/var/log/Xorg.0.log"
[ 3.635]
X.Org X Server 1.20.8
X Protocol Version 11, Revision 0
[ 3.635] Build Operating System: Linux Arch Linux
[ 3.635] Current Operating System: Linux msi 5.6.4-arch1-1 #1 SMP PREEMPT Mon, 13 Apr 2020 12:21:19 +0000 x86_64
[ 3.635] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=b6bdbe39-e79d-4e12-a07b-2b24b1e8d28a rw loglevel=3 quiet
[ 3.635] Build Date: 30 March 2020 05:05:45AM
[ 3.635]
[ 3.635] Current version of pixman: 0.38.4
[ 3.608] (--) Log file renamed from "/var/log/Xorg.pid-523.log" to "/var/log/Xorg.0.log"
[ 3.609]
X.Org X Server 1.20.8
X Protocol Version 11, Revision 0
[ 3.609] Build Operating System: Linux Arch Linux
[ 3.609] Current Operating System: Linux msi 5.6.4-arch1-1 #1 SMP PREEMPT Mon, 13 Apr 2020 12:21:19 +0000 x86_64
[ 3.609] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=b6bdbe39-e79d-4e12-a07b-2b24b1e8d28a rw loglevel=3 quiet
[ 3.609] Build Date: 30 March 2020 05:05:45AM
[ 3.609]
[ 3.609] Current version of pixman: 0.38.4
@nwg-piotr
nwg-piotr / amdgpu-pro log
Created April 18, 2020 20:11
This is what it looks like with amdgpu-pro.libl installed
[ 3.832] (--) Log file renamed from "/var/log/Xorg.pid-526.log" to "/var/log/Xorg.0.log"
[ 3.833]
X.Org X Server 1.20.8
X Protocol Version 11, Revision 0
[ 3.833] Build Operating System: Linux Arch Linux
[ 3.833] Current Operating System: Linux msi 5.6.4-arch1-1 #1 SMP PREEMPT Mon, 13 Apr 2020 12:21:19 +0000 x86_64
[ 3.833] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=b6bdbe39-e79d-4e12-a07b-2b24b1e8d28a rw loglevel=3 quiet
[ 3.833] Build Date: 30 March 2020 05:05:45AM
[ 3.833]
[ 3.833] Current version of pixman: 0.38.4
@nwg-piotr
nwg-piotr / amdgpu-pro log
Created April 18, 2020 20:11
This is what it looks like with amdgpu-pro.libl installed
[ 3.832] (--) Log file renamed from "/var/log/Xorg.pid-526.log" to "/var/log/Xorg.0.log"
[ 3.833]
X.Org X Server 1.20.8
X Protocol Version 11, Revision 0
[ 3.833] Build Operating System: Linux Arch Linux
[ 3.833] Current Operating System: Linux msi 5.6.4-arch1-1 #1 SMP PREEMPT Mon, 13 Apr 2020 12:21:19 +0000 x86_64
[ 3.833] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=b6bdbe39-e79d-4e12-a07b-2b24b1e8d28a rw loglevel=3 quiet
[ 3.833] Build Date: 30 March 2020 05:05:45AM
[ 3.833]
[ 3.833] Current version of pixman: 0.38.4
#!/usr/bin/env python3
for n in range(1000, 10000):
s = str(n)
result = (int(s[:2]) + int(s[2:])) ** 2
if n == result:
print(n)
exit(0) # actually it's unnecessary
@nwg-piotr
nwg-piotr / main.cpp
Created August 4, 2020 12:46
Pudges exercise in C++
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
for (int i=1000; i<10000; i++) {
std::string s = std::to_string(i);
int sum = std::stoi(s.substr(0, 2)) + std::stoi(s.substr(2, 2));
if (sum * sum == i) {
std::cout << i << "\n";
}