Skip to content

Instantly share code, notes, and snippets.

namespace ChironB.Benchmarks
open Chiron
open BenchmarkDotNet.Attributes
open Newtonsoft.Json
open Newtonsoft.Json.Linq
module Bench =
open System.IO
open System.Text
@ingted
ingted / getMovieTitles.py
Created April 10, 2022 10:48
getMovieTitles
import requests
def firstQuery(substr):
response = requests.get(f"https://jsonmock.hackerrank.com/api/movies/search/?Title={substr}")
respDict = response.json()
rtn = {
"per_page": respDict["per_page"], "total": respDict["total"], "total_pages": respDict["total_pages"]
}
return rtn
@ingted
ingted / getMaxOccurrences.py
Created April 10, 2022 10:46
getMaxOccurrences
#!/bin/python3
import math
import os
import random
import re
import sys
#
@ingted
ingted / iron_magic.py
Created March 7, 2022 05:57 — forked from maxhk/iron_magic.py
IronPython magic for iPython notebook
from __future__ import print_function
from IPython.core.magic import register_cell_magic
import subprocess as sp
import tempfile
import os
IRON_PYTHON_PATH = r'C:\HOMEWARE\IronPython-2.7.5\ipy64.exe'
@register_cell_magic
def iron(line, cell):
@ingted
ingted / gettingstarted-symbolicdifferentiation.fsx
Created March 5, 2022 05:56
Symbolic Differentiation of DiffSharp
//10bd8edbd5f0a13489931a75fdd21363a70c461e
//https://github.com/DiffSharp/DiffSharp/blob/10bd8edbd5f0a13489931a75fdd21363a70c461e/docs/input/gettingstarted-symbolicdifferentiation.fsx
```
(*** hide ***)
#r "../../src/DiffSharp/bin/Debug/FsAlg.dll"
#r "../../src/DiffSharp/bin/Debug/DiffSharp.dll"
(**
Symbolic Differentiation
========================
/// Source: GitHub Microsoft.ML
/// https://github.com/dotnet/machinelearning-samples/blob/master/samples/fsharp/common/ConsoleHelper.fs
/// New versions may reflect my own changes
/// MIT License
namespace Microsoft.ML.Extensions
open System
open Microsoft.ML
open Microsoft.ML.Data
// Renaming files
open System
open System.IO
[<Literal>]
let Folder = """P:\"""
@ingted
ingted / listAllEventListeners.js
Created May 22, 2021 01:57 — forked from tkafka/listAllEventListeners.js
List all event listeners in a document
console.table((function listAllEventListeners() {
const allElements = Array.prototype.slice.call(document.querySelectorAll('*'));
allElements.push(document); // we also want document events
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
let elements = [];
for (let i = 0; i < allElements.length; i++) {
@ingted
ingted / listAllEventListeners.js
Created May 22, 2021 01:57 — forked from dmnsgn/listAllEventListeners.js
List all event listeners in a document
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
@ingted
ingted / gist:5ad016bcf273fc8aebd6fd722c456bac
Created February 21, 2021 10:32 — forked from mathias-brandewinder/gist:d3daebd687f2095de1b1
Conversion to F# of "Gradient Descent Training Using C#"
// This is a conversion to F# of the C# code presented in
// MSDN Magazine, March 2015, by James McCaffrey:
// https://msdn.microsoft.com/en-us/magazine/dn913188.aspx
open System
let sumprod (v1:float[]) (v2:float[]) =
Seq.zip v1 v2 |> Seq.sumBy (fun (x,y) -> x * y)
let sigmoid z = 1.0 / (1.0 + exp (- z))