Skip to content

Instantly share code, notes, and snippets.

@matejc
matejc / rdp.sh
Created August 29, 2023 09:08
Unattended login into ARM RDP
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash freerdp3 gnugrep chromedriver jq
# Used for unattended (afk) logins
# My usecase:
# when machine locks its screen,
# there is no way to paste to paste longer password to login,
# so just close it and run this script again
#
# Conditions:
@matejc
matejc / trigger_debug_build.sh
Created April 18, 2020 18:23
Usage: $ trigger_debug_build.sh <job_id> <travis_token>
#!/usr/bin/env bash
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $2" \
-d "{\"quiet\": true}" \
https://api.travis-ci.org/job/$1/debug
@matejc
matejc / xrandr-rofi.sh
Last active March 3, 2019 20:33
rofi interface for xrandr
#!/usr/bin/env bash
set -e
state="$(xrandr)";
outputs="$(awk '{if ($2 == "connected") print $1}' <<< "$state")"
function getModes() {
awk -v output=$1 '{if ($1 == output) {getline; while ($0 ~ /^\ \ /) {print $1; getline;}}}' <<< "$state"
}
import sys
import logging
import tty
import termios
import argparse
import pychromecast
import threading
from pychromecast.controllers.youtube import YouTubeController
from urllib.parse import urlparse
from urllib.parse import parse_qs
@matejc
matejc / queue.js
Created December 11, 2017 08:23
local queue with concurrency
const PQ = require('p-q');
// so many parallel promises should run at the same time
const concurrency = 3;
// simulate work with delay function
function delay(times, ms = 1000) {
return new Promise((resolve) => {
setTimeout(resolve, times * ms);
});
@matejc
matejc / cycle_monitors.py
Created November 15, 2017 22:11
cycle through monitors with mouse
#!/usr/bin/env python3
import subprocess
import re
mouselocation = subprocess.check_output(['xdotool', 'getmouselocation']).decode('utf-8')
mouse = {
'x': int(mouselocation.split(' ')[0].split(':')[1]),
'y': int(mouselocation.split(' ')[1].split(':')[1])
}
async function test () {
let prefix = 'my-super-dooper-user-prefix';
await add(prefix, 'silver_hook', -2.6);
await add(prefix, 'Predkambrij', -2);
await add(prefix, 'offlinehacker', -200);
await add(prefix, 'offlinehacker', -200);
await add(prefix, 'offlinehacker', 2);
let transactions = await list(prefix, 'offlinehacker');
let balance = await get(prefix, 'offlinehacker');
console.log({transactions, balance})
# not to be used
{ pkgs ? import <nixpkgs> {} }:
pkgs.runCommand "vivaldi-with-flash" {
buildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${pkgs.vivaldi}/bin/vivaldi $out/bin/vivaldi \
--add-flags "--ppapi-flash-path=${pkgs.flashplayer}/lib/mozilla/plugins/libflashplayer.so"
''
{
name = "armv7l-hf-multiplatform-custom";
kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
kernelHeadersBaseConfig = "multi_v7_defconfig";
kernelBaseConfig = "multi_v7_defconfig";
kernelArch = "arm";
kernelDTB = true;
kernelAutoModules = false;
uboot = null;
kernelTarget = "zImage";
root@A20-OLinuXino:~/workarea/nix-1.11.4# make -j2
make: Warning: File 'config.h.in' has modification time 210856510 s in the future
GEN doc/manual/manual.xmli
GEN config.h
doc/manual/local.mk:21: recipe for target 'doc/manual/manual.xmli' failed
make: *** [doc/manual/manual.xmli] Error 1
make: *** Waiting for unfinished jobs....
root@A20-OLinuXino:~/workarea/nix-1.11.4# ls -lah config.h.in
-rw-r--r-- 1 30015 30000 3.4K Sep 6 2016 config.h.in