Skip to content

Instantly share code, notes, and snippets.

View sandcastle's full-sized avatar
🍦

Glenn Morton sandcastle

🍦
View GitHub Profile
@sandcastle
sandcastle / oracle_guid_helpers.sql
Last active April 29, 2024 08:19
Oracle GUID helper functions for converting between GUID and RAW(16)
set serveroutput on;
declare
raw_guid raw(16);
guid varchar2(64);
begin
raw_guid := guid_to_raw ('88c6a267-65d2-48d6-8da2-6f45e2c22726');
guid := raw_to_guid('67A2C688D265D6488DA26F45E2C22726');
@sandcastle
sandcastle / aurora_cluster.tf
Created March 25, 2016 09:44
Creates a AWS RDS Aurora Cluster with Terraform
########################
## Variables
########################
variable "environment_name" {
description = "The name of the environment"
}
variable "vpc_id" {
@sandcastle
sandcastle / timezones.ts
Created January 29, 2018 00:19
A timezone list with grouping by timezone, in TypeScript.
export interface IanaTimezone {
group: string;
timezone: string;
label: string;
}
export const IANA_TIMEZONES = [
// UTC+14:00
{ group: 'UTC+14:00', timezone: 'Pacific/Kiritimati', label: 'Pacific/Kiritimati (+14)' },
// UTC+13:00
@sandcastle
sandcastle / stringToColor.js
Created February 22, 2024 03:50
String to color converter
function stringToColor(str) {
// Predefined set of colors
const colors = ['#FF5733', '#33FF57', '#3357FF', '#F833FF', '#FF8333', '#33FFF8'];
// Simple hash function
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32bit integer
@sandcastle
sandcastle / install-teamcity.md
Last active December 7, 2023 18:02
Install TeamCity 9.0.3 on Ubuntu with Nginx
@sandcastle
sandcastle / pi-mount.sh
Last active March 4, 2023 21:05
Mount HFS+ USB Drive on a Raspberry Pi
sudo apt-get update
sudo apt-get upgrade -y
# install hfs tools (for macos extended journaled)
sudo apt-get install hfsplus hfsutils hfsprogs
sudo reboot
# get device id
df -h
# example:
@sandcastle
sandcastle / redirect-ingress.yml
Created August 27, 2017 02:07
An example of a ingress redirect using kubernetes and nginx `configuration-snippet`
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: redirect-ingress
annotations:
ingress.kubernetes.io/configuration-snippet: |
if ($host ~ ^(.+)\.somedomain\.io$) {
return 301 https://$1.domain.io$request_uri;
}
spec:
@sandcastle
sandcastle / Currency.cs
Created November 29, 2015 23:35
A data provider for all ISO countries in C#
public class Currency
{
/// <summary>
/// Gets or sets the ID of the currency.
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the ISO currency code.
/// </summary>
@sandcastle
sandcastle / GeoData.cs
Created May 4, 2016 14:30
A Unity 3D behaviour for Geo location lookup via IP address
using UnityEngine;
using System.Collections;
using Newtonsoft.Json;
/// <summary>
/// The Geo data for a user.
///
/// http://ip-api.com/docs/api:json
///
@sandcastle
sandcastle / copy-to-clipboard.ts
Created July 17, 2017 06:38
A copy to clipboard function (in typescript)
export const copyToClipboard = (url: string) => {
document.addEventListener('copy', (e: ClipboardEvent) => {
e.clipboardData.setData('text/plain', url);
e.preventDefault();
document.removeEventListener('copy');
});
document.execCommand('copy');
};