Skip to content

Instantly share code, notes, and snippets.

View stuaxo's full-sized avatar
💭
 

Stuart Axon stuaxo

💭
 
View GitHub Profile
@jaronkk
jaronkk / cleanup_docker.sh
Created June 2, 2016 14:11
Cleanup and reset docker on Jenkins workers / slaves
#!/bin/bash
# This script should be located on each Jenkins slave, and the jenkins user should have permission to run it with sudo
# Attempts to cleanly stop and remove all containers, volumes and images.
docker ps -q | xargs --no-run-if-empty docker stop
docker ps -q -a | xargs --no-run-if-empty docker rm --force --volumes
docker volume ls -q | xargs --no-run-if-empty docker volume rm
docker images -a -q | xargs --no-run-if-empty docker rmi -f
# Stops the docker service, unmounts all docker-related mounts, removes the entire docker directory, and starts docker again.
@NBonaparte
NBonaparte / gst-camera-record
Last active August 17, 2023 14:26
Python 3 program using Gstreamer 1.0 that shows video stream and allows for uninterrupted recording.
#!/usr/bin/python3
# This program is licensed under GPLv3.
from os import path
import gi
gi.require_version('Gst', '1.0')
gi.require_version('Gtk', '3.0')
gi.require_version('GdkX11', '3.0')
gi.require_version('GstVideo', '1.0')
from gi.repository import GObject, Gst, Gtk
@apolloclark
apolloclark / Twitter API with Curl
Last active December 15, 2024 00:46
Twitter API with Curl
# create an account, create an app
# @see https://apps.twitter.com/
# retrieve the access tokens
# @see https://dev.twitter.com/oauth/reference/post/oauth2/token
# create the file ~/twitter_api
nano ~/twitter_api
Authorization: OAuth oauth_consumer_key="XXXXXX", oauth_nonce="11111111", oauth_signature="XXXXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1450728725", oauth_token="99999-XXXXXX", oauth_version="1.0"
@lubosz
lubosz / gtksink-cairo.py
Created December 2, 2015 16:50
Python Interactive Cairo in GtkGLSink.
#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gst', '1.0')
import math
import cairo
from gi.repository import Gtk, Gst, Gdk
from IPython import embed
@rothnic
rothnic / collect_articles.py
Created September 25, 2015 00:42
Asyncio with ProcessPool to collect and process data about urls, using Newspaper
"""Collect article metadata and associate it with url dimension.
Currently the url dimension includes a domain and url, but there is
a higher level grouping that we care about. What is the outlet,
who authored the article, what kind of site is it, when was
it published, etc.
"""
import os
@DavidEGrayson
DavidEGrayson / msys2_env.bat
Last active December 10, 2021 09:20
My new favorite way to launch MSYS2
@echo off
cd %~dp0
set MSYSTEM=%~1
set _TERM=%~2
set _SH=%~3
set _ARGS=%~4
REM If MSYSTEM is empty, uses MSYS.
@evertrol
evertrol / gist:47325e62f8caae1b72ee
Last active February 16, 2021 13:16
Asyncio: cancel a set of coroutines from another coroutine, by stopping the event loop
"""Example to cancel a set of asyncio coroutines (futures),
using one coroutine to signal the event loop to stop.
"""
import asyncio
import logging
from datetime import datetime
from concurrent.futures import CancelledError
@VladSem
VladSem / tmux2_raspberry.sh
Created May 23, 2015 05:43
install tmux 2.0 on Raspberry Pi (Debian 7.8) Raspbian Wheezy
#!/bin/bash
wget "https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz"
tar -xf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure
make
make verify
sudo make install
sudo ldconfig
@sphaero
sphaero / gstseamlessloop.py
Last active December 23, 2023 09:50
Gstreamer seamless loop test
#/usr/bin/env python3
#
# Seamless loop test
# Copyright (c) 2015 Arnaud Loonstra <[email protected]>
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active March 24, 2025 20:20
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest