Skip to content

Instantly share code, notes, and snippets.

@odats
odats / gist:be5ca45e92e2af0119e01ef547361dc5
Last active December 28, 2021 15:07
Proofs of some simple intuitionistic propositional logic statement using Curry–Howard correspondence. Proposition as Type and a Proof as Program in OCaml.
(* Usefull links: *)
(* https://en.wikipedia.org/wiki/Brouwer–Heyting–Kolmogorov_interpretation *)
(* https://en.wikipedia.org/wiki/Intuitionistic_logic#Non-interdefinability_of_operators *)
(* Program = Proof, Book by Samuel Mimram, https://www.reddit.com/r/functionalprogramming/comments/k57s1y/program_proof_by_samuel_mimram_free_pdf/ *)
(* https://builds.openlogicproject.org/content/intuitionistic-logic/introduction/bhk-interpretation.pdf *)
(* https://math.stackexchange.com/questions/838184/can-one-prove-by-contraposition-in-intuitionistic-logic *)
(* Code: *)
type ('a , 'b) coprod = Left of 'a | Right of 'b
from ignite.metrics import Metric
from ignite.exceptions import NotComputableError
# These decorators helps with distributed settings
from ignite.metrics.metric import sync_all_reduce, reinit__is_reduced
# Based on https://pytorch.org/ignite/metrics.html#how-to-create-a-custom-metric
# Can be impoved by TopK https://pytorch.org/ignite/metrics.html#ignite.metrics.TopKCategoricalAccuracy
class PixelToPixelAccuracy(Metric):
@odats
odats / merging_line_segments.py
Created August 10, 2017 12:41
Implementation of merging line segments by TAVARES and PADILHA
# TAVARES and PADILHA approach
def merge_line_segments(line_i, line_j, use_log=False):
# line distance
line_i_length = math.hypot(line_i[1][0] - line_i[0][0], line_i[1][1] - line_i[0][1])
line_j_length = math.hypot(line_j[1][0] - line_j[0][0], line_j[1][1] - line_j[0][1])
# centroids
Xg = line_i_length*(line_i[0][0]+line_i[1][0]) + line_j_length*(line_j[0][0]+line_j[1][0])
Xg /= 2 * (line_i_length + line_j_length)
@odats
odats / FB Like
Created February 13, 2013 17:17 — forked from matclayton/FB Like
<div id="fb-root"></div>
<script>
(function() {
window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create', function(response) {
_gaq.push(['_trackSocial', 'facebook', 'like', response]);
});
FB.Event.subscribe('edge.remove', function(response) {
_gaq.push(['_trackSocial', 'facebook', 'unlike', response]);
});
@odats
odats / app.yaml
Created November 15, 2011 12:09 — forked from Arachnid/app.yaml
application: filehangar
version: live
runtime: python
api_version: 1
handlers:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
@odats
odats / gist:1345775
Created November 7, 2011 18:40
recorder
var recorderWidget = new RecorderWidget({closeCallback:function(){alert("close me")}});
showRecordDialog(recorderWidget.render().el);
RecorderView = Backbone.View.extend({
isRecordReady = false,
recordType,
// parent dialog holder