Skip to content

Instantly share code, notes, and snippets.

View tludlow's full-sized avatar
🖐️

Thomas Ludlow tludlow

🖐️
  • London, United Kingdom
  • 20:16 (UTC +01:00)
View GitHub Profile
@tludlow
tludlow / tailwind-indicator.tsx
Created November 25, 2025 14:16
Helpful indicator showing the viewport size for tailwind breakpoints - copied from shadcn
const SHOW = true
export function TailwindIndicator() {
if (process.env.NODE_ENV === "production" || !SHOW) {
return null
}
return (
<div
data-tailwind-indicator=""
@tludlow
tludlow / winston.js
Created April 2, 2023 16:30
Required changes to make winston.js send 'INFO' level logs to the instana dashboard
/*
* (c) Copyright IBM Corp. 2021
* (c) Copyright Instana Inc. and contributors 2018
*/
'use strict';
const requireHook = require('../../../util/requireHook');
const tracingUtil = require('../../tracingUtil');
const constants = require('../../constants');
@tludlow
tludlow / annealing.py
Created January 13, 2020 13:36
annealing swaps
def getDayAndSlotFromSessionNumber(self, number):
#Have to minus 1 from the number as sessions start at 1 and indices start at 0
if number >= 1 and number <= 10:
return 0, number-1
elif number >= 11 and number <= 20:
return 1, number-11
elif number >= 21 and number <= 30:
return 2, number-21
elif number >= 31 and number <= 40:
return 3, number-31
@tludlow
tludlow / makerobotarm.sh
Created January 13, 2019 06:08
Shell script to compile the robot arm program and run it.
#!/bin/sh
gcc -o skeleton_halfway.c\
sleep 500ms
make skeleton_halfway
./skeleton_halfway
@tludlow
tludlow / scanMotor.sh
Created January 13, 2019 05:58
A shell script to return the value of a motor on the robot arm
#!/bin/sh
scanMotors="→ ./bin/scan /dev/ttyUSB0 "
# Get the correct line for the motor required, motor 01 on line 2, motor 05 on line 6.
if [ "$1" = "01" ]
then
return scanMotors | sed -n '2p' #Return the second line of the command output to the user for the 1st motor.
elif [ "$1" = "02" ]
then
return scanMotors | sed -n '3p' #Return the third line of the command output to the user for the 2nd motor.
@tludlow
tludlow / recursivetowersofhanoi.c
Last active January 8, 2019 23:56
A recursive implementation of the tower of hanoi problem in the c programming language
#include <stdio.h>
//towersOfHanoi - Recursive solution to the towers of hanoi with n blocks.
// int n - The size of the starting tower.
// int startTower - The identity of the starting tower, is an integer.
// int endTower - The identity of the ending tower, is an integer
void towersOfHanoi(int n, int startTower, int endTower, int storageTower) {
//Base case, if theres on 1 block present move from the start tower to the end tower and we are done.
if (n == 1) {
printf("Moving block from tower %d to tower %d \n", startTower, endTower);
@tludlow
tludlow / towersofhanoi.c
Last active January 8, 2019 21:04
working towers of hanoi
#include "dynamixel.h"
#include <stdio.h>
#include <time.h>
#include <unistd.h>
//Moves the robot motor given in id to the value specified in loc_l 0xff is fully extended vertically. Range is between 0x00 and 0xff
void move_to_location(int connection, unsigned char id, unsigned char loc_h, unsigned char loc_l) {
//~ = Bitwise complement (flips the bits)
unsigned char cs = ~ ( id + 0x07 + 0x03 + 0x1e + loc_l + loc_h + 0x30 + 0x00);
@tludlow
tludlow / asdasd
Created November 25, 2018 18:50
graph induction
https://math.stackexchange.com/questions/1054448/number-of-edges-induction-proof