Skip to content

Instantly share code, notes, and snippets.

View unclechu's full-sized avatar

Viacheslav Lotsmanov unclechu

View GitHub Profile
@unclechu
unclechu / pajack.sh
Created January 21, 2017 14:14
pajack.sh
#!/bin/bash
exec 0</dev/null
if [ "$1" == "on" ]; then
# if jack-server isn't already running
if ! pidof "jackd" 1>&- 2>&-; then
jackd -dalsa -dhw:USB -r44100 -p512 -n3 -i2 -o2 1>/dev/null &
sleep 2
@unclechu
unclechu / xorg.conf
Created February 2, 2017 22:59
My tearing-free Xorg config for Radeon R7 360
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib64/xorg/modules"
FontPath "catalogue:/etc/X11/fontpath.d"
@unclechu
unclechu / gtk2-example.pl6
Created March 20, 2017 18:32
gtk2-example.pl6
#!/usr/bin/env perl6
use v6;
use NativeCall;
class GtkWidget is repr('CPointer') {}
sub gtk_init(CArray[int32] $argc, CArray[CArray[Str]] $argv) is native('gtk') {*}
sub gtk_window_new(int32 $window_type --> GtkWidget) is native('gtk') {*}
sub gtk_main() is native('gtk') {*}
sub gtk_window_set_title(GtkWidget $window, Str $title) is native('gtk') {*}
#!/usr/bin/env perl6
use v6;
close $*IN;
my Int $line-limit := 60;
my Str $BS := "\c[BACKSPACE]";
my Str $UP := "\c[ESCAPE][1A";
sub show-message(Str $message) {
my Str @args = Q:w <dzen2 -p -bg red -fg white -fn -*-sans-bold-*-*-*-*-*-*-*-*-*-*-*>;
my Proc::Async $proc := Proc::Async.new(:w, |@args);
@unclechu
unclechu / automating-slack-message-deleting.js
Created April 18, 2017 13:11
automating-slack-message-deleting.js
(() => {
const isDeletingInProgress = () => {
const el = document.querySelector('.modal-body');
return el.innerText === 'Deleting messages...';
};
const waitFor = (f, timeout = 500) => new Promise(resolve => {
const r = () => {
const value = f();
@unclechu
unclechu / both-dbus.hs
Last active April 26, 2017 23:19
haskell: dbus: testing many receivers
#!/usr/bin/env stack
{-
stack
--resolver lts-7.21
--install-ghc
runghc
--package base-unicode-symbols
--package dbus
--package X11
-}
@unclechu
unclechu / 01-servant-basic-auth.hs
Last active June 3, 2017 23:02
haskell-servant-progress
-- Author: Viacheslav Lotsmanov
-- License: AGPLv3
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@unclechu
unclechu / genpass.pl6
Last active February 4, 2018 14:11
genpass.pl6
#!/usr/bin/env perl6
use v6.c;
sub MAIN(Int $count = 8, Bool :$special-chars = False) {
my Str @more-chars;
@more-chars.append: '#@&$%_-=+~*^\|/;:,.?!'.split: '', :skip-empty
if $special-chars;
my \chars = (('a'..'z'), ('A'..'Z'), ('0'..'9'), @more-chars)
@unclechu
unclechu / x11-xlib-opacity.hs
Created June 10, 2017 15:56
Haskell X11 Xlib set opacity in percents
-- …
setOpacityPercent ∷ Display → Window → Integer → IO ()
setOpacityPercent dpy wnd (toRational → percent) = do
opacityAtom ← internAtom dpy "_NET_WM_WINDOW_OPACITY" False
withArrayLen [x] $ \len ptr →
() <$ xChangeProperty dpy wnd opacityAtom cARDINAL 32 propModeReplace
(castPtr ptr) (fromIntegral len)
@unclechu
unclechu / docker-copy-volume.sh
Last active July 27, 2017 10:17
docker-copy-volume.sh
#!/bin/bash
if [[ -z $1 ]] || [[ -z $2 ]]; then
echo Usage: "$(basename -- "$0")" \
SOURCE-VOLUME-ID DESTINATION-VOLUME-ID 1>&2
exit 1
fi
docker run --rm -it -v "$1:/vol-src" -v "$2:/vol-dst" alpine \
ash -c 'cp -r /vol-src/* /vol-dst/' || exit $?