Skip to content

Instantly share code, notes, and snippets.

View njam's full-sized avatar

Reto Kaiser njam

View GitHub Profile
(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'}
Q: How big is the blockchain today?
A: 415'000 blocks, 70 Gigabytes.
Q: Where is the blockchain stored?
A: On all the nodes participating in the Bitcoin p2p network.
Implicit consensus is achieved by all nodes following the same rules (and incentives).
Q: What kind of encryption is Bitcoin using?
A: none (rather hashing and signing).
@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

Keybase proof

I hereby claim:

  • I am njam on github.
  • I am njam (https://keybase.io/njam) on keybase.
  • I have a public key ASC-YBOm7q4wL-uRQU9id9E7Z4dRkDiF8Dqn1q5gL6341Ao

To claim this, I am signing this object:

@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 / 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
"""
package main
func printDiff(suppressedKinds []string, kind string, context int, before, after string, to io.Writer) {
diffs := difflib.Diff(strings.Split(before, "\n"), strings.Split(after, "\n"))
for _, ckind := range suppressedKinds {
if ckind == kind {
str := fmt.Sprintf("+ Changes suppressed on sensitive content of type %s\n", kind)
fmt.Fprintf(to, ansi.Color(str, "yellow"))
return
<?xml version="1.0" encoding="utf-8"?>
<CityModel xmlns="http://www.opengis.net/citygml/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xAL="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gml="http://www.opengis.net/gml"
xmlns:bldg="http://www.opengis.net/citygml/building/2.0"
xmlns:wtr="http://www.opengis.net/citygml/waterbody/2.0"
xmlns:veg="http://www.opengis.net/citygml/vegetation/2.0"
xmlns:dem="http://www.opengis.net/citygml/relief/2.0"
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::*;