Skip to content

Instantly share code, notes, and snippets.

View gpolitis's full-sized avatar
👾

George Politis gpolitis

👾
View GitHub Profile
@gpolitis
gpolitis / build.xml
Created February 29, 2012 15:26
Ant sample build.xml
<?xml version="1.0"?>
<project name="the project" default="compile" basedir=".">
<property name="src.dir" location="src" />
<property name="bin.dir" location="bin" />
<property name="lib.dir" location="lib" />
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
@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 / 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 / gist:1116968
Created July 31, 2011 17:03
Fix Number of Hidden Sectors in NTFS Bios Parameter Block
#!/bin/sh
DEVICE=$1
SECTOR=$(sfdisk -luS|grep $DEVICE|gawk '{print $2}')
echo $SECTOR | gawk '{printf("%c%c%c%c",$1,rshift($1,8),rshift($1,16),rshift($1,24))}' | dd bs=1 count=4 seek=28 of=$DEVICE
@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 / 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 / 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