Skip to content

Instantly share code, notes, and snippets.

View OnorioCatenacci's full-sized avatar

Onorio Catenacci OnorioCatenacci

View GitHub Profile
@OnorioCatenacci
OnorioCatenacci / CheckForConn.fs
Last active December 18, 2015 10:39
F# Code To Check For Connection Type With Xamarin.Android
open Android.App
open Android.Content
open Android.Net
let IsConnectionAvailable (app:Activity) connTypeToCheckFor =
let n = app.GetSystemService(Context.ConnectivityService)
let cm =
match n with
@OnorioCatenacci
OnorioCatenacci / fortunecookie.fsx
Created October 10, 2013 12:56
Connect F# To Access Via Odbc
open System
open System.Data.Odbc
open System.Windows.Forms
let connectToAccess filename =
let connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;FileDSN=" + filename + ";User Id=admin;Password=;"
new OdbcConnection(connectionString)
let connectToDb() =
@OnorioCatenacci
OnorioCatenacci / LiteralWithFormatString.fs
Created October 10, 2013 18:49
Trying to use [<Literal>] with Format String
[<Literal>]
let formatString = "format of %s"
let s = sprintf formatString "test"
@OnorioCatenacci
OnorioCatenacci / ExecFsx.ps1
Created November 11, 2011 20:11
Quick Powershell Script For Running Fsharp Shell Scripts
#11 November 2011
#ExecFsx.ps1
#Onorio Catenacci
#Insure we get all the error checking from Powershell itself that we can
set-strictmode -version latest
#Set this to point at the location of fsi.exe on your machine.
set-variable -name fsi -value """$env:ProgramFiles\Microsoft F#\v4.0\fsi.exe""" -option constant
#This is where I put all of my .fsx files. Change this to your favorite location
@OnorioCatenacci
OnorioCatenacci / TicTacToeGame.tla
Created November 3, 2020 21:16
Initial state of TicTacToe Game
--------------------------- MODULE TicTacToeGame ---------------------------
VARIABLE boardPositions, turn
tokens == {"X","O","V","-"} (* V == "Vacant", - == "Doesn't matter" *)
row == <<tokens, tokens, tokens>>
grid == <<row, row, row>>
col_1_Win(token) == <<
<<token, "-", "-">>,
<<token, "-", "-">>,
<<token, "-", "-">>

Two Kinds Of Elixir Constants

What Do I Mean By 'Constant'?

First it feels appropriate to say that when I say constant I have a definite technical meaning in mind. In a mathematical sense a constant like pi or e is simply a value that's fixed on the number line. In the sense that software developers use the word "constant" we usually mean something which is an extension of the notion of a mathematical constant--a fixed value. It could be a number or a string or even a more complex data structure; the point is that in the course of the normal execution of the binary it won't change.

Here I'm using the term constant to name a value that needs to be referenced in two or more modules in Elixir which none of them will change. The value will be defined in one module and then read from others. There are two reasons to do this approach:

  1. It makes the code more readable
  2. It keeps the developer from repeating his/her self.
@OnorioCatenacci
OnorioCatenacci / DigitScript.fsx
Last active December 4, 2022 08:25
Machine Learning Dojo
// This F# dojo is directly inspired by the
// Digit Recognizer competition from Kaggle.com:
// http://www.kaggle.com/c/digit-recognizer
// The datasets below are simply shorter versions of
// the training dataset from Kaggle.
// The goal of the dojo will be to
// create a classifier that uses training data
// to recognize hand-written digits, and
// evaluate the quality of our classifier