Skip to content

Instantly share code, notes, and snippets.

View KellerII's full-sized avatar
💻

KellerII

💻
View GitHub Profile
@KellerII
KellerII / main.go
Last active October 20, 2023 19:13
Quick Go Program to Compare CSV and YAML Files
package main
import (
"encoding/csv"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
@KellerII
KellerII / ColorWrapper.swift
Created April 23, 2016 17:57
A simple enum wrapper for generating color objects using RGB or HSB values.
import UIKit
enum ColorComponents {
case RGB(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)
case HSB(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat)
func color() -> UIColor {
switch self {
case .RGB(let redValue, let greenValue, let blueValue, let alphaValue):
return UIColor(red: redValue/255.0, green: greenValue/255.0, blue: blueValue/255.0, alpha: alphaValue)
@KellerII
KellerII / Quicksort.java
Last active April 23, 2016 17:58
Quicksort
/**
* Sorts the specified array of objects using the quick sort
* algorithm.
*/
public static <T extends Comparable<? super T>> void quickSort (T[] data, int min, int max)
{
int indexofpartition;
if (max - min > 0)
{
@KellerII
KellerII / MergeSort.java
Last active April 23, 2016 17:59
Merge Sort
/**
* Sorts the specified array of objects using the merge sort
* algorithm.
*/
public static <T extends Comparable<? super T>> void mergeSort (T[] data, int min, int max)
{
T[] temp;
int index1, left, right;
//Return on list of length one
@KellerII
KellerII / InsertionSort.java
Last active April 23, 2016 17:59
Insertion Sort
/**
* Sorts the specified array of objects using an insertion
* sort algorithm.
*/
public static <T extends Comparable<? super T>> void insertionSort (T[] data)
{
for (int index = 1; index < data.length; index++)
{
T key = data[index];
int position = index;
@KellerII
KellerII / BinarySearch.java
Last active April 23, 2016 17:59
Binary Search
/**
* Searches the specified array of objects using a binary search
* algorithm.
*/
public static <T extends Comparable<? super T>> boolean binarySearch (T[] data, int min, int max, T target)
{
boolean found = false;
int midpoint = (min + max) / 2; //Determine the midpoint
if (data[midpoint].compareTo(target) == 0)
@KellerII
KellerII / SelectionSort.java
Last active April 23, 2016 18:00
Selection Sort
/**
* Sorts the specified array of integers using the selection
* sort algorithm.
*/
public static <T extends Comparable<? super T>> void selectionSort (T[] data)
{
int min;
T temp;
for (int index = 0; index < data.length-1; index++)