Skip to content

Instantly share code, notes, and snippets.

View MarkTuddenham's full-sized avatar
🇬🇧

Mark Tuddenham MarkTuddenham

🇬🇧
View GitHub Profile
@MarkTuddenham
MarkTuddenham / profiler.py
Last active February 24, 2022 09:49
Python function profiler decorator
from typing import Optional
from typing import Union
from typing import Tuple
from typing import Collection
from typing import Callable
from typing import Any
import sys
import cProfile
@MarkTuddenham
MarkTuddenham / check_convex.py
Created April 6, 2021 11:32 — forked from mblondel/check_convex.py
A small script to get numerical evidence that a function is convex
# Authors: Mathieu Blondel, Vlad Niculae
# License: BSD 3 clause
import numpy as np
def _gen_pairs(gen, max_iter, max_inner, random_state, verbose):
rng = np.random.RandomState(random_state)
# if tuple, interpret as randn
@MarkTuddenham
MarkTuddenham / enable-webcam
Created April 29, 2020 13:56
command to enable DSLR/Mirrorless as a webcam.
#!/bin/bash
gphoto2 --stdout --capture-movie | gst-launch-1.0 fdsrc ! decodebin3 name=dec ! queue ! videoconvert ! v4l2sink device=/dev/video1
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignEscapedNewlines: Left
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortLambdasOnASingleLine: Inline
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MarkTuddenham
MarkTuddenham / ieee.csl
Created October 26, 2019 21:20
IEEE citation styling
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">
<info>
<title>IEEE</title>
<id>http://tudders.dev/ieee</id>
<link href="http://www.zotero.org/styles/ieee-with-url" rel="self"/>
<link href="http://www.ieee.org/documents/style_manual.pdf" rel="documentation"/>
<link href="http://www.ieee.org/documents/auinfo07.pdf" rel="documentation"/>
<author>
<name>Michael Berkowitz</name>
@MarkTuddenham
MarkTuddenham / raspbian_setup.sh
Last active September 7, 2019 11:03
Basic setup script for a fresh Raspbian install
#!/bin/bash
# Basic setup script for a fresh Raspbian install.
# Run logged in to root:
# curl -LSs https://gist.github.com/MarkTuddenham/252b8471d9d653ac0ef2717eee091b3f/raw/raspbian_setup.sh | /bin/bash -s <your_user_name>
if [[ $(id -u) -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
@MarkTuddenham
MarkTuddenham / .vimrc
Last active March 1, 2021 15:36
Basic vim setup script
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
@MarkTuddenham
MarkTuddenham / update-vscode
Created August 25, 2019 09:01
Auto Updater for VS Code on Linux
#!/bin/bash
# put in /usr/local/bin
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
wget https://vscode-update.azurewebsites.net/latest/linux-deb-x64/stable -O /tmp/code_latest_amd64.deb
dpkg -i /tmp/code_latest_amd64.deb
@MarkTuddenham
MarkTuddenham / simple_regex.py
Last active May 24, 2019 13:38
Create simple regex expression from examples: 'simple_regex aa_bb_cc.py aa.pyc' -> aa*.py*
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Simple regex creator.
Creates regex expressions from examples.
"""
from typing import Set
import sys