Skip to content

Instantly share code, notes, and snippets.

@h3
h3 / stream.js
Created May 13, 2020 — forked from saghul/stream.js
Streaming a webcam to a Jitsi Meet room
View stream.js
const puppeteer = require('puppeteer');
// Streams the first webcam in the system to the specified Jitsi Meet room. Audio is currently
// not sent, but it can be easily enabled by disabling the corresponding setting in `meetArgs`.
//
// TODO
// - Detect if we are kicked from the room
// - Support authenticated deployments
//
@h3
h3 / readme.md
Created May 14, 2019 — forked from gregf/readme.md
Private networking on ovh with proxmox
View readme.md

On your proxmox server edit /etc/interfaces and add a vmbr1 interface like so

auto lo
iface lo inet loopback

auto vmbr0
iface vmbr0 inet static
        address  167.114.101.88
        netmask  255.255.255.0
@h3
h3 / github-exodus.sh
Last active Jun 4, 2018
Check recursively if repositories have been migrated to Gitlab
View github-exodus.sh
#!/bin/bash
#
# Example usage:
#
# $ ./github-exodus.sh .
# $ ./github-exodus.sh venv/src/
#
README_EXTENSIONS=('.md' '.rst' '.txt' '')
@h3
h3 / color.py
Last active Jun 27, 2019
Simple shell color outpout function
View color.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
import sys
def c(i):
"""
@h3
h3 / pip.sh
Created Jun 8, 2017
pip madness
View pip.sh
$ pip install pip
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip install pip --upgrade pip
@h3
h3 / trynetconf.sh
Last active Dec 18, 2015
Try networking configuration and set a restore time (tested on Ubuntu)
View trynetconf.sh
#/bin/sh
RESTART="/etc/init.d/networking restart"
FILEPATH="/etc/network/interfaces"
BACKUPPATH="$FILEPATH.BAK"
RESET_TIME="now + ${1:-5min}"
sudo cp -fp $FILEPATH $BACKUPPATH && \
sudoedit $FILEPATH && \
sudo bash -c "echo 'cp -fp $BACKUPPATH $FILEPATH && $RESTART' | at $RESET_TIME" && \
@h3
h3 / getdict.py
Created May 15, 2013
Returns a dict from a dict list given a matching key value pair and returns None if no matches.
View getdict.py
def get_dict_from_list(l, k, v):
"""
Returns a dict from a dict list given a matching key value pair
and returns None if no matches.
>>> test = [{'A': 'a1', 'B': 'b1'}, {'B': 'b2', 'A': 'a2', }]
>>> get_dict_from_list('A', 'a2')
{'B': 'b2', 'A': 'a2', }
"""
@h3
h3 / watch.sh
Last active Dec 16, 2015
Bootstrap's watch functionality, without the dependencies (and bugs) 1) Put it in your bootstrap folder witht he filename "watch.sh" 2) Then chmod a+x watch.sh 3) Use ./watch.sh to run.
View watch.sh
#!/bin/bash
# Credits:
# v1 (original code): Ian Vaughan (http://stackoverflow.com/a/4960140/105905)
# v2 (Minor changes): Maxime Haineault (https://gist.github.com/h3/5446756)
sha=0
previous_sha=0
update_sha()
View gist:3912404
def dotted_line(**kwargs):
out = []
width = kwargs.get('right') - kwargs.get('left')
dash = kwargs.pop('dash')
dashcount = width / dash
new_kwargs = kwargs.copy()
new_kwargs['left'] = kwargs.get('left') - (dash * 2)
for d in range(0, int(dashcount)):
new_kwargs['left'] = new_kwargs['left'] + dash + dash
new_kwargs['right'] = new_kwargs['left'] + dash
@h3
h3 / gist:3037571
Created Jul 3, 2012
Get first element of a QuerySet
View gist:3037571
def getLastDateModification(self):
qs = self.themefile_set.order_by('-date_modified')
# NEVER !!
return qs[0].date_modified
# The most efficient/failsafe way (this will add LIMIT 1 to the query):
rs = list(qs[:1])
return rs and rs[0].date_modified or None