Skip to content

Instantly share code, notes, and snippets.

@MartinHarding
MartinHarding / clone-repos.py
Last active September 28, 2017 13:00
Clone repositories from a given organization into working directory
""" Clone repositories from a given organization into working directory """
import os
import re
import subprocess
import requests
token = os.environ.get('GITHUB_TOKEN', False)
if not token:
print('GITHUB_TOKEN envar not set, enter one to clone private repositories')
@MartinHarding
MartinHarding / git-sync.sh
Created October 27, 2017 18:31
A simple bash script to run git pull in a directory of repos
#!/usr/bin/env bash
# A simple bash script to run git pull in a directory of repos. Automatically
# detects whether each directory is a git repository, and can optionally
# checkout a branch before pulling using the `-b <branch-name>` argument.
# Save original working directory
_ORIGINAL_PWD="$PWD"
# Parse args
from pathfinding.core.diagonal_movement import DiagonalMovement
from pathfinding.core.grid import Grid
from pathfinding.finder.a_star import AStarFinder
matrix = [
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1],
[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
[0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0],
// Launch Arc Renderer for Unity 3D from this Tutorial (with minor fixes):
// https://www.youtube.com/watch?v=iLlWirdxass
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent (typeof(LineRenderer))]
public class LaunchArcRenderer : MonoBehaviour {
@MartinHarding
MartinHarding / social-login.py
Created March 6, 2018 22:40
Flask-Dance Social Login Examples
# Super quick and dirty example of social login with Github, Facebook, Twitter, and Google using Flask-Dance
from flask import Flask, redirect, url_for
from werkzeug.contrib.fixers import ProxyFix
from flask_dance.contrib.github import make_github_blueprint, github
from flask_dance.contrib.twitter import make_twitter_blueprint, twitter
from flask_dance.contrib.facebook import make_facebook_blueprint, facebook
from flask_dance.contrib.google import make_google_blueprint, google
from flask import request
import json
@MartinHarding
MartinHarding / Dockerfile
Last active October 16, 2020 16:19
Passlib on AWS Lambda Example
# Amazon Linux version that Lambda runs
FROM amazonlinux:2017.03.1.20170812
# Install Python 3.6.1 and zip
RUN yum -y update
RUN yum -y install curl zip openssl openssl-devel gcc zlib-devel
WORKDIR /tmp
RUN curl -o Python-3.6.1.tgz https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
RUN tar zxf Python-3.6.1.tgz
WORKDIR /tmp/Python-3.6.1

Keybase proof

I hereby claim:

  • I am martinharding on github.
  • I am martinharding (https://keybase.io/martinharding) on keybase.
  • I have a public key whose fingerprint is 7911 AA11 3ACD F6FA 380C F6D5 7001 F342 FCF1 B123

To claim this, I am signing this object:

@MartinHarding
MartinHarding / rasbpian-configure.sh
Last active January 6, 2019 21:08
Configure SSH and WiFi on a newly flashed Rasbpian SD card
#!/bin/bash
# Quickly enable SSH and configure WiFi settings on a newly flashed Rasbpian SD card.
# Note: this script is meant to be run from the machine used to flash the SD card, not from the Raspberry Pi!
# Run script without downloading (Windows users will need either git-bash or cygwin):
# bash <(curl -s https://gist.githubusercontent.com/martinharding/f86d44067adff7352f3d8091cf1b666c/raw/rasbpian-configure.sh)
# Determine SD card mount point
case $OSTYPE in
msys | cygwin )
@MartinHarding
MartinHarding / picamera-streamer.sh
Last active January 6, 2019 23:29
Quickly setup a basic video stream from a Raspberry Pi and Pi Camera module
#/bin/bash
# Sets up Miguel Grinberg's excellent Flask video streaming example to automatically start on boot using the PiCamera
# Run script without downloading (must be logged into Raspberry Pi):
# curl -s https://gist.githubusercontent.com/martinharding/b3c31cf93ed581f6be2519f9957c3f7c/raw/picamera-streamer.sh -o picamera-streamer.sh && chmod +x picamera-streamer.sh && ./picamera-streamer.sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# First install!
@MartinHarding
MartinHarding / toggle_mouse_button.lua
Last active October 28, 2023 10:35
Logitech Gaming Software Mouse Button Toggle script
-- Toggles a mouse button when you press another mouse button.
-- 1. Change your mouse to "Automatic Game Detection" mode
-- 2. Right click on a profile's icon and choose scripting
-- 3. Paste this into the default profile script box, save, enjoy!
toggle_button = 7 -- What mouse button should control the toggle
button_to_toggle = 1 -- What button to toggle
button_toggled = false
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == toggle_button then
button_toggled = not button_toggled