Skip to content

Instantly share code, notes, and snippets.

Avatar

Matej Cotman matejc

View GitHub Profile
@matejc
matejc / trigger_debug_build.sh
Created Apr 18, 2020
Usage: $ trigger_debug_build.sh <job_id> <travis_token>
View trigger_debug_build.sh
#!/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 Mar 3, 2019
rofi interface for xrandr
View xrandr-rofi.sh
#!/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"
}
View chromecast.py
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 Dec 11, 2017
local queue with concurrency
View queue.js
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 Nov 15, 2017
cycle through monitors with mouse
View cycle_monitors.py
#!/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])
}
View owe-machine-test.js
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})
View vivaldi-with-flash-mozilla.nix
# 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"
''
View platform.nix
{
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";
View beje?.txt
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
View get_options.json
{
"type": "dict",
"meta": {},
"value": {
"build_script": {
"type": "file",
"meta": {},
"value": "builders/overrider.nix"
},
"override": {
You can’t perform that action at this time.