Skip to content

Instantly share code, notes, and snippets.

View gpolitis's full-sized avatar
👾

George Politis gpolitis

👾
View GitHub Profile
@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
@gpolitis
gpolitis / debug.md
Last active September 2, 2020 09:08
  1. quit Chrome (Cmd+Q)
  2. start it like this from the cmd line script ~/Desktop/debug.log /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-logging=stderr --vmodule=*/webrtc/*=3
  3. screen-share something, for example your most embarassing tab

P.S. if you use zsh you need to put quotes around the chrome parameters

@gpolitis
gpolitis / 99-incoming-tcp-connection-gw-override.sh
Last active July 13, 2023 17:07 — forked from Shourai/Allowing SSH on a server with an active OpenVPN client.md
Allowing SSH on a server with an active OpenVPN client
#!/bin/sh
# based on https://gist.github.com/Shourai/1088f78b5e3696190a8ce6a6045c477b
if [ $# -lt 2 ]; then
echo "Usage: $0 interface up|down" 1>&2
exit 1;
fi
DEV=$1
@gpolitis
gpolitis / Jitsi.xml
Last active January 26, 2017 21:36
Jitsi Coding Convention for IntelliJ IDEA
<code_scheme name="Jitsi">
<option name="USE_SINGLE_CLASS_IMPORTS" value="false" />
<option name="RIGHT_MARGIN" value="80" />
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="JAVA">
<option name="BRACE_STYLE" value="2" />
<option name="CLASS_BRACE_STYLE" value="2" />