Skip to content

Instantly share code, notes, and snippets.

View stuaxo's full-sized avatar
💭
 

Stuart Axon stuaxo

💭
 
View GitHub Profile
@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
@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.
@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
@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
@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"
@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
@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.
@moonhouse
moonhouse / steps.sh
Created September 16, 2016 19:40
Installing apcmm on MacOS X
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
pip install cython
brew install liblo
pip install -r requirements.txt
python setup.py install
pip install pygame
brew install portmidi
@aras-p
aras-p / sampler.hlsl
Created February 13, 2017 12:13
Default sampler states in HLSL :(
// HLSL does allow initializing sampler states with a syntax
// like this. However the state settings themselves are nowhere
// to be found in the compiled shader bytecode (as of d3dcompiler_47.dll
// 10.0.14393 from Win10 SDK), and can't be accessed via ID3D11ShaderReflection
// either.
//
// Looks like the compiler only emits the sampler default values if compiling
// the deprecated "effect file" target.
//
// SAD!
@Brainiarc7
Brainiarc7 / qt5-cxrosscompile-env-for-rpi.md
Created March 2, 2017 17:45
Setting up a Raspberry Pi QT5 cross compile environment on Linux

Generating an environment on Linux to cross-compile QT applications for a Raspberry Pi running Debian Wheezy:

Grab tools (for the cross-compiler tool chain) and firmware (for the OpenGL libraries) from the Raspberry Pi GitHub repository:

git clone https://github.com/raspberrypi/tools.git --depth=1
git clone https://github.com/raspberrypi/firmware.git --depth=1

Copy OpenGL stuff to the toolchain's sysroot: