Skip to content

Instantly share code, notes, and snippets.

View jageall's full-sized avatar

James Geall jageall

  • Aardware Ltd
  • Netherlands
View GitHub Profile
@jageall
jageall / SemverSort.ps1
Last active March 15, 2022 19:09
Sorts semver in powershell
#powershell script port of https://github.com/maxhauser/semver/
function toSemVer($version){
$version -match "^(?<major>\d+)(\.(?<minor>\d+))?(\.(?<patch>\d+))?(\-(?<pre>[0-9A-Za-z\-\.]+))?(\+(?<build>[0-9A-Za-z\-\.]+))?$" | Out-Null
$major = [int]$matches['major']
$minor = [int]$matches['minor']
$patch = [int]$matches['patch']
if($matches['pre'] -eq $null){$pre = @()}
else{$pre = $matches['pre'].Split(".")}
@jageall
jageall / GuidGenerator.cs
Created July 15, 2014 09:22
Guid from name
public class GuidGenerator
{
public static Guid CreateGuidFromName(Guid @namespace, string name)
{
return CreateGuidFromName(@namespace, name, 5);
}
//Implements rfc 4122
public static Guid CreateGuidFromName(Guid @namespace, string name, int version)
{
@jageall
jageall / gist:7906685
Created December 11, 2013 08:10
Randomish chat message generator
using System;
using Newtonsoft.Json.Linq;
namespace ConsoleApplication3 {
class Program {
static void Main(string[] args) {
Random rnd = new Random();
var names = new[] {"James", "Greg", "Tomas", "Rob", "Matias", "Roberto", "Ronan"};
var text = new[] {"Hi","herpy", "derpy", "herpherp", "derpderp", "chocolate", "moose", "put the moose in the chocolate", "ponies", "starbucks", "happy"};
JArray events = new JArray();
@jageall
jageall / gist:7906655
Created December 11, 2013 08:06
sample data 2
[
{
"eventId": "0851995c-8a68-42cf-8035-c7976e07de48",
"eventType": "ChatMessage",
"data": {
"sender": "Greg",
"message": "Hi",
"time": "03:45:30"
}
},
@jageall
jageall / gist:7906643
Created December 11, 2013 08:04
sample data
[
{
"eventId": "954d8152-a9e8-4bfc-be7b-1c637900a853",
"eventType": "ChatMessage",
"data": {
"sender": "Rob",
"message": "starbucks",
"time": "03:45:30"
}
},