Skip to content

Instantly share code, notes, and snippets.

View praeclarum's full-sized avatar

Frank A. Krueger praeclarum

View GitHub Profile
@dvdhfnr
dvdhfnr / midas_loss.py
Last active April 14, 2024 15:15
Loss function of MiDaS
import torch
import torch.nn as nn
def compute_scale_and_shift(prediction, target, mask):
# system matrix: A = [[a_00, a_01], [a_10, a_11]]
a_00 = torch.sum(mask * prediction * prediction, (1, 2))
a_01 = torch.sum(mask * prediction, (1, 2))
a_11 = torch.sum(mask, (1, 2))
using System;
using OSX.Foundation;
class Driver {
static void Main (string[] args) {
var str = new NSString ("This is an objc string");
Console.WriteLine ("Dump: {0} {1}", str == null, str);
}
}
basalt:OSX.x64.Debug plasma$ ./corerun -c . hw.exe
@praeclarum
praeclarum / MarkovChain.fs
Last active August 29, 2015 14:13
Markov Chain that learns by observing data.
/// Markov chain that learns by observing data.
/// Let it observe a sequence of states.
/// Then you can ask it, given a state,
/// what are the probabilities of the next states occuring?
/// This chain can remember history to make better predictions.
type MarkovChain (numStates : int, memory : int) =
let numPrevious = 1 + memory
let matrixSize = int (System.Math.Pow (float numStates, float numPrevious))
@praeclarum
praeclarum / AutoLayout.fs
Last active April 27, 2020 11:07
AutoLayout wrapper to make creating constraints in F# easier
module Praeclarum.AutoLayout
open System
#if __IOS__
open Foundation
open UIKit
type NativeView = UIView
#else
open Foundation
@bradwilson
bradwilson / vs2013-normal-menus.ps1
Created November 2, 2013 16:55
Say goodbye to VS2013's SHOUTING MENUS
Set-ItemProperty -Path HKCU:\Software\Microsoft\VisualStudio\12.0\General -Name SuppressUppercaseConversion -Type DWord -Value 1
@ssajous
ssajous / Dice.cs
Last active October 14, 2021 15:41
Implementations of Dice's Coefficient used to get a similarity index between two strings.
public static double DiceCoefficient(string stOne, string stTwo)
{
HashSet<string> nx = BuildBigramSet(stOne);
HashSet<string> ny = BuildBigramSet(stTwo);
HashSet<string> intersection = new HashSet<string>(nx);
intersection.IntersectWith(ny);
double dbOne = intersection.Count;
return (2 * dbOne) / (nx.Count + ny.Count);
@theburningmonk
theburningmonk / FSharpSerialization.fsx
Created March 18, 2012 12:54
Serializing/Deserializing F# Record and DU types
#r "System.Xml.dll"
#r "System.Runtime.Serialization.dll"
open Microsoft.FSharp.Reflection
open System.IO
open System.Reflection
open System.Runtime.Serialization
open System.Runtime.Serialization.Formatters.Binary
open System.Runtime.Serialization.Json
open System.Text
<CustomCommands>
<CustomCommands>
<Command type="BeforeBuild" command="rm -rf ${SolutionDir}/Output/Payload/${ProjectName}.app/" />
<Command type="BeforeBuild" command="rm -rf ${SolutionDir}/${ProjectName}.ipa" />
<Command type="AfterBuild" command="cp -r ${ProjectDir}/bin/${ProjectConfigPlat}/${ProjectConfigName}/${ProjectName}.app ${SolutionDir}/Output/Payload/${ProjectName}.app" workingdir="" />
<Command type="AfterBuild" command="zip -r ../${ProjectName}.ipa ." workingdir="${SolutionDir}/Output/" />
<Command type="AfterBuild" command="curl http://testflightapp.com/api/builds.json -F file=@../${ProjectName}.ipa -F api_token='<your_api_token>' -F team_token='<your_team_token>'' -F notes='Uploaded Automatically From MonoDevelop' -F notify=false -F distribution_lists='<any dist lists you want to include>'" />
</CustomCommands>
</CustomCommands>