Skip to content

Instantly share code, notes, and snippets.

Phillip Trelford ptrelford

Block or report user

Report or block ptrelford

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ShorterExceptions.cs
using System;
using static Exceptions;
class MainClass
{
public static void Main(string[] args)
{
throw NRE;
}
}
View SayGoodbyeToVarCSharp5AndLower.cs
using System;
using System.Xml;
class MainClass : Variables
{
public static void Main(string[] args)
{
new MainClass().StaticIsEvilForSure();
}
View SayGoodbyeToVar.cs
using System;
using System.Xml;
using static Variables;
class MainClass
{
public static void Main(string[] args)
{
for (i = 0; i < 10; i++)
{
@ptrelford
ptrelford / JsonParser.js
Created May 16, 2016
Custom Json Parser in vanilla JavaScript
View JsonParser.js
JSON={
parse:function(str,options) {
this.str = str;
this.i = 0;
this.nfirstchars = '-0123456789.';
this.nchars = '-0123456789.eE';
this.n
return this.parseValue();
},
isWhiteSpace:function(c) {
View JsonParser.fs
type json =
| Number of float
| String of string
| Boolean of bool
| Array of json list
| Object of (string * json) list
| Null
static member (?) (this,name:string) =
match this with
| Object xs -> xs |> List.find (fst >> (=) name) |> snd
@ptrelford
ptrelford / timeline.fs
Last active Apr 23, 2016
Generates a responsive timeline of F# meetups around the world
View timeline.fs
#r @"packages/FSharp.Data/lib/net40/FSharp.Data.dll"
#load "FsHtml.fs" // "paket-files/ptrelford/FsHtml/src/FsHtml.fs"
open System
open FSharp.Data
open FsHtml
type Events = JsonProvider<"https://api.meetup.com/fsharplondon/events?&sign=true&photo-host=public&page=200&status=past,upcoming">
let meetups = [
@ptrelford
ptrelford / SnowflakesMono.fsx
Created Dec 15, 2015
Snowflakes falling using MonoGame
View SnowflakesMono.fsx
#r "System.Drawing.dll"
#r "System.Windows.Forms.dll"
#r @"./packages/MonoGame.Framework.WindowsDX.3.4.0.459/lib/net40/MonoGame.Framework.dll"
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
open Microsoft.Xna.Framework.Input
module Text =
open System.IO
@ptrelford
ptrelford / FallingSnowflakes.fsx
Last active Dec 14, 2015
Falling Snowflakes (as F# strings) using WPF canvas
View FallingSnowflakes.fsx
#r "PresentationCore.dll"
#r "PresentationFramework.dll"
#r "WindowsBase.dll"
open System
open System.Windows
open System.Windows.Controls
open System.Windows.Media
let w, h = 800.0, 600.0
@ptrelford
ptrelford / SnowflakesEx.fsx
Last active Dec 15, 2015
Falling Snowflakes F# script using WriteableBitmapEx
View SnowflakesEx.fsx
#r "PresentationCore.dll"
#r "PresentationFramework.dll"
#r "WindowsBase.dll"
#r "WriteableBitmapEx.Wpf.dll" // requires custom version with DrawString
open System
open System.Windows
open System.Windows.Controls
open System.Windows.Media
open System.Windows.Media.Imaging
View randomArt.go
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"math/rand"
"os"
You can’t perform that action at this time.