This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import ranger.api | |
import subprocess | |
# https://github.com/ranger/ranger/wiki/Signals-and-Hooks | |
def ranger_signal_bind(signal_name): | |
def decorate(handler): | |
old_hook_ready = ranger.api.hook_ready | |
def hook_ready(fm): | |
fm.notify('%s %r' % (signal_name, handler)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo hcitool lescan | |
AA:BB:CC:DD:EE:FF Polar H10 ABCDEFGH | |
$ gatttool -t random --device=AA:BB:CC:DD:EE:FF --interactive | |
[AA:BB:CC:DD:EE:FF][LE]> connect | |
Attempting to connect to AA:BB:CC:DD:EE:FF | |
Connection successful | |
[AA:BB:CC:DD:EE:FF][LE]> primary | |
attr handle: 0x0001, end grp handle: 0x0009 uuid: 00001800-0000-1000-8000-00805f9b34fb | |
attr handle: 0x000a, end grp handle: 0x000d uuid: 00001801-0000-1000-8000-00805f9b34fb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Sabre\HTTP\RequestInterface; | |
use \Sabre\HTTP\ResponseInterface; | |
class SabreDavYii2AuthBackend implements \Sabre\DAV\Auth\Backend\BackendInterface | |
{ | |
function check(RequestInterface $request, ResponseInterface $response) | |
{ | |
if(\Yii::$app->user->isGuest) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python-xlib's Xlib.display.next_event() does not have a timeout when waiting for an event to be queued. | |
It may block the script's execution forever. | |
Workaround: | |
Call display.next_event() only if an event is available in the queue. | |
Use select.select() on the xserver's socket to wait for an event and specify a timeout. | |
based on: https://stackoverflow.com/a/8592969/5894777 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Display names of outputs available to the X server similiar to 'xrandr' command. | |
Access xlib and xrandr extension via python's ctypes library. | |
tags: x11, xorg, x.org, xwindow-system, xlib, libx, xrandr, outputs, monitor, display | |
""" | |
import ctypes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -lgcrypt ... | |
#include <assert.h> | |
#include <gcrypt.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
const size_t KEYGRIP_LENGTH = 20; | |
unsigned char* read_binary(const char* path, size_t* bytes_read) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <security/pam_appl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> // getpass | |
// apt install libpam0g-dev | |
// compile with flag -lpam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
> sstream = io.StringIO() | |
> subprocess.run(['hostname'], stdout=sstream, check=True) | |
io.UnsupportedOperation: fileno | |
""" | |
import os | |
import select |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import select | |
DEFAULT_BUFFER_SIZE_BYTES = 8196 | |
DEFAULT_READ_TIMEOUT_SECONDS = 1.0 | |
def rselect(fd, timeout_seconds=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://forum.pine64.org/showthread.php?tid=1297&pid=15958#pid15958 | |
$ fdtget --type x /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/eth@01c30000 reg | |
0 1c30000 0 10000 0 1c00000 0 30 | |
# https://forum.pine64.org/showthread.php?tid=1297&pid=16138#pid16138 | |
$ fdtget /boot/pine64/sun50i-a64-pine64-plus.dtb /aliases spi0 | |
/soc@01c00000/spi@01c68000 | |
$ fdtget /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000 status | |
disabled | |
$ sudo fdtput --verbose --type s /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000 status okay |
OlderNewer