Skip to content

Instantly share code, notes, and snippets.

View JamesPhillipsUK's full-sized avatar
🏳️‍🌈
Building fabulous software.

Jesse Phillips JamesPhillipsUK

🏳️‍🌈
Building fabulous software.
View GitHub Profile
@JamesPhillipsUK
JamesPhillipsUK / plotHistogram.md
Created October 11, 2022 11:46
Plotting frequency distribution of multiple metrics in Python.

By popular request - here's the script I've been using to plot histograms of the comparative frequency distribution of data using Python.

This script takes a list of any size, where the contents are tuples containing a list of floating-point data, and a name for that data.

For example:

...
# copy or import the plotHistogram script here.
...
""" helloworld.py
A simple Hello World python script.
Authors: Jesse Phillips <james@jamesphillipsuk.com>
"""
def main():

Here's my implementation of a BubbleSort algorithm in Python.
I've also taken the opportunity to update my C and PHP BubbleSort Gist from a few years ago.
This was written using Python 3.8.10.

@JamesPhillipsUK
JamesPhillipsUK / SelectionSort in C and Python.md
Created July 6, 2021 20:57
SelectionSort in C and Python

Here's my implementation of a SelectionSort algorithm in C and Python.
It's fairly verbose and easy to read, but could probably do with a cleanup at some point. The C version was written using GCC 9.3.0, and the Python version was written using Python 3.8.10.

@JamesPhillipsUK
JamesPhillipsUK / bresenham.c
Created July 22, 2020 12:17
Bresenham's Line Drawing Algorithm implemented in C and ncurses.
/**
* Bresenham's Line Drawing Algorithm implemented in C and ncurses.
* Based on https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#C - there are probably better ways than doing this.
**/
#include <stdlib.h>
#include <ncurses.h>
/** Implement Bresenham's Line Drawing Algorithm. **/
void drawBresenhamLine(int startXLocation, int startYLocation, int endXLocation, int endYLocation)
@JamesPhillipsUK
JamesPhillipsUK / Depth-First Filesystem Traversal in PHP.md
Last active December 28, 2019 17:07
Depth-First Filesystem Traversal in PHP

Depth-First Filesystem Traversal in PHP

Whilst working on BlogDraw-Updater earlier this week, I created a nifty little system for filesystem traversal in PHP which I thought I'd share with you all because it might be useful. At the very least, it could save a couple of people some time writing something like this out themselves.

It uses depth-first traversal to locate every file in a filesystem, implemented through a recursive function (traverse). "traverse" takes a filepath (either relative, or absolute) to a directory and locates all files and directories within it. It also locates all files and directories in those directories, and so on until it's mapped out the entire filesystem.

Conventions

I've chosen to demonstrate a couple of unusual conventions here, namely:

@JamesPhillipsUK
JamesPhillipsUK / BubbleSort.c
Last active July 6, 2021 20:51
Simple Example Bubble Sort Algorithms
/**
* Bubble Sort Algorithm.
*
* @author Jesse Phillips
**/
#include <stdio.h> /*Standard I/O Library*/
#include <stdlib.h> /*Standard Library - Handles EXIT_SUCCESS*/
#include <stdbool.h> /*Standard Boolean Library*/
int data[] = {21,2,3,4,10,6277,71,948,8,140};
@JamesPhillipsUK
JamesPhillipsUK / get_avatar.php
Created September 14, 2018 11:39
Get avatars.io Avatar in PHP
<?php
/**
* Get avatars.io Avatar URL or image tag.
* $nwk is the social media network, $unm is the username, $img is whether you want the image over the url.
**/
function get_avatar($nwk, $unm, $img)
{
$url = 'https://avatars.io';
$url .= '/' . $nwk;
$url .= '/' . $unm;
@JamesPhillipsUK
JamesPhillipsUK / Basic JavaScript Accessibility Tools using jQuery.md
Last active July 18, 2018 08:48
Basic JavaScript Accessibility Tools using jQuery

Some Basic JS Accessibility Tools using jQuery

I've had this code lying around for a while now, and I only really use it on one website, because most people that need it have software that can do it for them. I thought other people may find it more useful than I do. So, feel free to use it.

The Code

  • accessibility.html, this contains the two buttons I use for increased accessibility. It also calls jQuery's CDN (but you can use locally hosted jQuery if you want), and it calls the accessibility.js script.
  • accessibility.js, this contains a jQuery event handler for each button, containing an anonymous function to handle the button's intended operation.

Get in touch

https://jamesphillipsuk.com/contact