Skip to content

Instantly share code, notes, and snippets.

View heuristicus's full-sized avatar

Michal Staniaszek heuristicus

  • Oxford Robotics Institute
  • Oxford
View GitHub Profile
@heuristicus
heuristicus / dropdown_filter_combobox.cpp
Last active April 5, 2022 13:29
Implement a combobox where the entries are filtered by the line edit
// Initialise the combobox for the edge selection
// listmodel stores the actual data. This will be populated when we get a map update
edgeIDModel = new QStringListModel();
// Set the model for the combobox as the base stringlist model. If we use the same filter model for both the
// combobox and the completer, there will be weird behaviour, probably because the two objects are fighting
// to define what is in the list of strings.
actionComboBox->setModel(edgeIDModel);
// Need a completer so that the combobox pops up with possible options given typed text
edgeIDCompleter = new QCompleter();
edgeIDCompleter->setParent(parent);
@heuristicus
heuristicus / pre-commit.sh
Last active October 27, 2023 10:35
Tiny modification to default git pre-commit hook to check black output formatting
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
@heuristicus
heuristicus / rpy_to_quat.py
Created June 4, 2021 12:05
Converting roll,pitch,yaw to quaternion with transforms3d
#!/usr/bin/env python
import math
import argparse
from transforms3d.euler import euler2quat, quat2euler
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("roll", type=float)
parser.add_argument("pitch", type=float)
parser.add_argument("yaw", type=float)
@heuristicus
heuristicus / get_repo.sh
Last active March 5, 2021 11:54
Try to get a git repository as written, but if the clone fails, check if it's an ssh clone and if so try again with a https clone
# You may prefer to use ssh -A if the reason you need to use this script is because the machine you are cloning on
# doesn't have access to private repositories. This will use ssh credentials from your machine rather than the local ones.
function get_repo() {
# Try to clone the repository as given, but if it fails, check if the url was via ssh, and try to clone
# with https instead. This is useful if you don't have an ssh key with access to private repositories, but do
# have credentials
# Use $@ to make sure we catch stuff like -b branch_name and so on
git clone "$@"
# If the command fails, maybe it's because of ssh. Check if the repo string $1 contains "git@"
@heuristicus
heuristicus / clang-tidy-git.sh
Created February 3, 2021 15:50
Apply clang-tidy fixes to a codebase and make each fix an individual commit
# This script runs clang-tidy on code to apply its checks for modernisation and readability, applying the fix for each
# check and creating a git commit for it.
# To set up conditions for this file
# 1. Compile your code with the flag -DCMAKE_COMPILE_COMMANDS=ON
# 2. go into the build directory for whatever package you are interested in - it will contain a compile_commands.json file.
# 3. Link compile_commands.json to wherever you have your git repostitory for the code with ln -s
# 4. Run this script in the git repository
# Get the checks we are going to apply to the code, skip the first line which is "enabled checks:" from the clang-tidy output
checks=(`clang-tidy -list-checks -checks="-*,readability*,modernization*" | tail -n +2`)
@heuristicus
heuristicus / git_organisation.py
Last active December 2, 2020 10:47
Get details of ori-drs organisation repositories by using the github API
#!/usr/bin/env python
# This script hooks into the github API to make it easy and quick to add repositories and people to teams in
# github organisations.
import sys
import getpass
import argparse
import github
@heuristicus
heuristicus / synced_save.cpp
Created September 28, 2018 09:25
Synchronised saver for two image streams coming from ROS, useful for rgb+depth image saving
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <image_transport/subscriber_filter.h>
#include <cv_bridge/cv_bridge.h>
#include <opencv2/highgui/highgui.hpp>
#include <boost/format.hpp>
#include <boost/thread.hpp>
#include <boost/filesystem.hpp>
Implement a thing which labels clusters which have partial information https://en.wikipedia.org/wiki/Transduction_(machine_learning)
@heuristicus
heuristicus / gist:5879781
Last active December 19, 2015 01:59
Ultimate noughts and crosses
http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/
@heuristicus
heuristicus / stardrawer.txt
Created May 17, 2013 19:32
Little GUI based program in C++ for drawing stars based on some properties
1. Define a set of points which are arranged on a circle
2. Connect points by a line
2.1 Which points are connected is defined by some step value - a value of 4 means that you connect point 0 to point 3, for example
Should be good practice for a little C++ programming, and a nice plaything.
Allow definition of number of points and the step - a slider would be nice to see the patterns made
Make it so that the lines can be drawn in real time if desired - gives an idea of the construction process.