Skip to content

Instantly share code, notes, and snippets.

View njam's full-sized avatar

Reto Kaiser njam

View GitHub Profile
@njam
njam / arch-linux
Last active July 13, 2023 06:54
Install Arch Linux on XPS 13 9360
# Installation on Dell XPS
# Please also consult official documentation:
# https://wiki.archlinux.org/index.php/Installation_Guide
# https://wiki.archlinux.org/index.php/Dell_XPS_13_(9360)
# https://wiki.archlinux.org/index.php/Dell_XPS_15_(9550)
# Enter BIOS with F2 and configure:
# - "System Configuration" > "SATA Operation": "AHCI"
# - "Secure Boot" > "Secure Boot Enable": "Disabled"
@njam
njam / measure.sh
Created July 5, 2016 09:04
Measure bandwidth with tcpstat + gnuplot
# Measure traffic with tcpstat
tcpstat -i em1 -o "%r\t%b\n" -s 30 0.1 > traffic.txt
# Create plot using the below script
gnuplot traffic.script > traffic.png
# Display plot
qlmanage -p 2>/dev/null traffic.png
@njam
njam / asyncio_pool.py
Created October 13, 2017 18:24
Limit number of concurrently running asyncio tasks
import asyncio
from collections import deque
class AsyncioPool:
def __init__(self, concurrency, loop=None):
"""
@param loop: asyncio loop
@param concurrency: Maximum number of concurrently running tasks
"""
(function($) {
function visible(element) {
return $.expr.filters.visible(element) && !$(element).parents().addBack().filter(function() {
return $.css(this, 'visibility') === 'hidden';
}).length;
}
function focusable(element, isTabIndexNotNaN) {
var map, mapName, img, nodeName = element.nodeName.toLowerCase();
if ('area' === nodeName) {
@njam
njam / repo-list-license.js
Last active February 21, 2020 16:07
List license of all repos in a Github organisation
var GitHubApi = require('github');
var assert = require('assert');
var org = 'cargomedia';
var token = '<github-token>';
var api = new GitHubApi({
version: '3.0.0',
protocol: 'https',
headers: {'user-agent': 'repo-lister'}
@njam
njam / restic-backup@.service
Last active February 15, 2020 10:52
restic systemd config
[Unit]
Description=Restic backup %I
[Service]
Type=oneshot
Environment="HOME=%h"
ExecStart=/usr/bin/restic backup $BACKUP_ARGS "${BACKUP_PATH}"
ExecStart=/usr/bin/restic forget --prune $FORGET_ARGS
ExecStart=/usr/bin/restic check
@njam
njam / dominator-headless.rs
Created February 5, 2020 19:21
Rendering rust-dominator app in headless browser with wasm-bindgen-test
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
use wasm_bindgen_test::wasm_bindgen_test_configure;
use dominator_test::App;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test(async)]
async fn test_html() {
use std::pin::Pin;
use std::rc::Rc;
use std::task::Poll;
use futures_executor::block_on;
use futures_util::future::poll_fn;
use futures_signals::signal::{Mutable, Signal};
use futures_signals::signal_vec::{MutableVec};
use futures_signals::signal_vec::SignalVecExt;
#[test]
fn filter_signal_cloned() {
let list = signal_vec::always(vec![3, 1, 6, 2]).map(Rc::new);
#[derive(Copy, Clone)]
enum FilterOption { Odd, Even }
let filter_option = Rc::new(Mutable::new(FilterOption::Odd));
let mut signal = list
extern crate gtk;
extern crate gio;
extern crate glib;
#[macro_use]
extern crate relm;
#[macro_use]
extern crate relm_derive;
use relm::{Relm, Update, Widget};
use gio::prelude::*;