Skip to content

Instantly share code, notes, and snippets.

View gpolitis's full-sized avatar
👾

George Politis gpolitis

👾
View GitHub Profile
@gpolitis
gpolitis / SS.java
Last active October 26, 2024 09:59
/*
* Copyright (c) 2024 Georgios Politis
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
@gpolitis
gpolitis / JURL.java
Created October 24, 2024 18:13
a super tiny Java class to fetch a file from the Internet
/*
* Copyright (c) 2024 Georgios Politis
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
@gpolitis
gpolitis / qemu.sh
Last active October 6, 2024 10:44
A kiss wrapper script for qemu
#!/usr/bin/env bash
#
#Copyright 2024 Georgios Politis
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the “Software”), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
@gpolitis
gpolitis / OpenQASM.tex
Created December 15, 2023 18:59
OpenQASM language definition for LaTeX listings
% original author Thomas Wong https://twitter.com/thomasgwong/status/1067202788487245824?lang=en
\lstdefinelanguage{OpenQASM}{
morekeywords={qreg,creg,include,gate,opqaue,U,CX,measure,reset,if,barrier,u3,u2,u1,cx,id,x,y,z,h,s,sdg,t,tdg,rx,ry,rz,cz,cy,ch,ccx,crz,cu1,cu3},
sensitive=true,
morecomment=[l]{//},
morestring=[b]"
}
@gpolitis
gpolitis / rtcstats-cookbook.md
Last active July 6, 2022 10:06
A collection of recipes for dealing with rtcstats

How to access Redshift?

Amazon Redshift is a data warehouse product based on PostgreSQL. You can access the rtcstats databases HERE. We have a prod and a pilot database, use accordingly. Use username "admin" and "temporary credentials" to authenticate.

How to query/find all the sessions/endpoints in a call?

In this context a session equals an endpoint. The column name is statssessionid. If you know the meeting unique id and you want to find all the endpoints/sessions in that call this SQL query will do:

SELECT statssessionid FROM "rtcstats"."public"."rtcstats"
@gpolitis
gpolitis / popcorntime-vpn.sh
Created October 16, 2021 10:40 — forked from Schnouki/popcorntime-vpn.sh
OpenVPN for a single application using network namespaces -- helper scripts
#!/usr/bin/env zsh
# Initialize VPN
sudo vpnns up
sudo vpnns start_vpn
# Popcorn time!
sudo ip netns exec frootvpn sudo -u $USER popcorntime
# Cleanup
#!/usr/bin/env python3
import numpy as np
# A: the array with the possible last-n values
# B: the array with the calls (where each element X represents a X-peeps call)
# returns a matrix where each row "i" is a vector of how many LD streams a
# participant in call "j" would receive.
def product(A, B):
res = np.empty([len(A), len(B)])
#!/bin/sh -x
errexit() {
echo "$1"
exit 1
}
usage() {
echo "Usage: $0 wrap -c file command"
echo " $0 reset -c file command"
@gpolitis
gpolitis / xhyvemake-instance.sh
Last active January 22, 2020 13:31
A helper script to create xhyve virtual machines with cloud-init support.
#!/bin/sh
# Copyright (c) 2020 Georgios Politis
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
XHYVE_HOME=${XHYVE_HOME:-"$HOME/Virtual Machines"}
oups () {
echo "$1" 1>&2
exit 1
@gpolitis
gpolitis / csvio.py
Created November 28, 2019 10:02
Python script that efficiently drops columns from a CSV file
import csv
import sys
START = 0
STOP = 1
STEP = 1
# adjust the constants and then use like this:
# cat CSV_FILE | python csvio.py | less -S