Skip to content

Instantly share code, notes, and snippets.

View voronoipotato's full-sized avatar

Alan Ball voronoipotato

  • NC
View GitHub Profile
@voronoipotato
voronoipotato / generate_series.sql
Created July 26, 2018 21:54 — forked from sebastianwebber/generate_series.sql
SQL Server generate_series
-- http://blog.jooq.org/2013/11/19/how-to-create-a-range-from-1-to-10-in-sql/
IF EXISTS (SELECT *
FROM dbo.sysobjects
WHERE id = object_id (N'[dbo].[generate_series]')
AND OBJECTPROPERTY(id, N'IsTableFunction') = 1)
DROP FUNCTION [dbo].[generate_series]
GO
CREATE FUNCTION [dbo].[generate_series] ( @p_start INT, @p_end INT)
// Learn more about F# at http://fsharp.org
open Microsoft.ML
open Microsoft.ML.Runtime.Api
open Microsoft.ML.Trainers
open Microsoft.ML.Transforms
open System
//The first four properties are inputs, the label is what you are predicting which is set in training
type IrisData() =
[<Column("0")>] [<DefaultValue>]
open System.IO
#I @"/lib/mono/gtk-sharp-3.0"
#r "atk-sharp.dll"
#r "gio-sharp.dll"
#r "glib-sharp.dll"
#r "gtk-sharp.dll"
#r "gdk-sharp.dll"
module Tarot =
let mutable handSize = 5
let shuffle a =
@voronoipotato
voronoipotato / Memoize.fs
Created April 2, 2018 14:11
Decent Memoize function in F#
let memoize f =
let cache = ref Map.empty
fun x ->
match (!cache).TryFind(x) with
| Some res -> res
| None ->
let res = f x
cache := (!cache).Add(x,res)
res
#r "WindowsBase"
#r "PresentationCore"
#r "PresentationFramework"
open System.Windows
open System.Windows.Controls
type Action =
| Increment
@voronoipotato
voronoipotato / base64-web-safe.js
Created January 23, 2018 19:38 — forked from geraintluff/base64-web-safe.js
Convert base64 to and from web-safe variant
// Convert from normal to web-safe, strip trailing "="s
function webSafe64(base64) {
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
// Convert from web-safe to normal, add trailing "="s
function normal64(base64) {
return base64.replace(/\-/g, '+').replace(/_/g, '/') + '=='.substring(0, (3*base64.length)%4);
}
#r "WindowsBase"
#r "PresentationCore"
#r "PresentationFramework"
open System.Windows
open System.Windows.Controls
type Action =
| Increment
type Magma<'a> =
abstract member append : 'a -> 'a -> 'a
type Semigroup<'a> =
inherit Magma<'a>
type Monoid<'a> =
inherit Semigroup<'a>
abstract member empty : 'a
@voronoipotato
voronoipotato / fizzbuzz_in_DBN.fsx
Created September 26, 2017 20:56 — forked from paralax/fizzbuzz_in_DBN.fsx
i ported that "fizzbuzz in tensorflow" to F# and Accord.Net's DeepBeliefNetwork
// i ported that "fizzbuzz in tensorflow" to F# and Accord.Net's DeepBeliefNetwork
// http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
#r "Debug/Accord.dll"
#r "Debug/Accord.Math.dll"
#r "Debug/Accord.Neuro.dll"
#I "Debug"
open Accord.Neuro
open Accord.Neuro.Networks
async.map(myUrls, function(url, callback) {
request(url, function(error, response, html) {
// Some processing is happening here before the callback is invoked
callback(error, html);
});
}, function(err, results) {
...
});