Skip to content

Instantly share code, notes, and snippets.

using System;
using static Exceptions;
class MainClass
{
public static void Main(string[] args)
{
throw NRE;
}
}
using System;
using System.Xml;
class MainClass : Variables
{
public static void Main(string[] args)
{
new MainClass().StaticIsEvilForSure();
}
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 08:56
Custom Json Parser in vanilla JavaScript
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) {
@ptrelford
ptrelford / JsonParser.fs
Last active May 7, 2018 14:05
JSON Parser
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 April 23, 2016 16:36
Generates a responsive timeline of F# meetups around the world
#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 December 15, 2015 22:40
Snowflakes falling using MonoGame
#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 December 14, 2015 21:45
Falling Snowflakes (as F# strings) using WPF canvas
#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 December 15, 2015 19:01
Falling Snowflakes F# script using WriteableBitmapEx
#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
@ptrelford
ptrelford / randomArt.go
Created September 5, 2015 12:09
Random Art
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"math/rand"
"os"