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 / logical.nix
Created October 10, 2016 11:19
nixops example with nixos-conteiner
{ cert ? "", key ? "" }: {
server = { config, pkgs, ... }: {
services.openssh.enable = true;
services.panamax.enable = false;
};
hidden = { config, lib, pkgs, ... }: with lib; {
options = {
owncloudHost = lib.mkOption {
default = "";
@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"
''
@matejc
matejc / pushnotify.py
Created June 29, 2016 00:28
weechat pushbullet notification
# -*- coding: utf-8 -*-
import re
import json
import weechat
from urllib2 import Request
from urllib2 import urlopen