Skip to content

Instantly share code, notes, and snippets.

View joom's full-sized avatar

Joomy Korkut joom

View GitHub Profile
@ranjitjhala
ranjitjhala / FizzBuzz.hs
Created March 23, 2015 17:50
Fizz-Buzz in LiquidHaskell
// Run at: http://goto.ucsd.edu:8090/index.html#?demo=permalink%2F1427132944.hs
module FizzBuzz where
---------------------------------------------------------------
-- | Implementation: Top level
---------------------------------------------------------------
main :: IO ()
main = mapM_ (putStrLn . say) (take 100 $ nums 0)
@david-christiansen
david-christiansen / NatInd.idr
Last active October 26, 2017 22:21
Simple proof automation with reflected elaboration
module NatInd
import Language.Reflection.Elab
import Language.Reflection.Utils
%default total
trivial : Elab ()
trivial = do compute
g <- snd <$> getGoal
@metanet
metanet / kmeans.scala
Created May 3, 2015 18:16
K-Means clustering with Scala
import java.io.File
import java.lang.Math.{pow, sqrt}
import scala.annotation.tailrec
import scala.util.Random
case class Point(x: Double, y: Double, z: Double) {
def distanceTo(that: Point) = sqrt(pow(this.x - that.x, 2) + pow(this.y - that.y, 2) + pow(this.z - that.z, 2))
def sum(that: Point) = Point(this.x + that.x, this.y + that.y, this.z + that.z)
@patik
patik / how-to-squash-commits-in-git.md
Last active October 13, 2025 09:47
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

import Language.Reflection.Elab
namespace Tactics
||| Restrict a polymorphic type to () for contexts where it doesn't
||| matter. This is nice for sticking `debug` in a context where
||| Idris can't solve the type.
simple : {m : Type -> Type} -> m () -> m ()
simple x = x
@biboudis
biboudis / power.ml
Last active October 8, 2018 18:09
Staged power, with fixed, with staged fix.
(* http://fssnip.net/sE in BER MetaOCaml *)
open Runcode;;
let rec fix : (('a -> 'b) -> ('a -> 'b)) -> 'a -> 'b = fun f x ->
f (fix f) x;;
let fix' : (('a -> 'b) code -> ('a -> 'b) code) -> ('a -> 'b) code = fun f ->
.< fun x -> let rec loop x = (fun f' -> .~(f .<f'>.) ) loop x in
loop x >.;;
@puffnfresh
puffnfresh / Compose.agda
Last active February 23, 2021 03:44
Functors compose
module Compose where
open import Level
open import Function
open import Relation.Binary.PropositionalEquality
record Functor {α} (T : Set α → Set α) : Set (suc α) where
field
map : ∀ {A B : Set α} → (A → B) → T A → T B
identity : ∀ {A : Set α} → map id ≡ id {A = T A}
@goldfirere
goldfirere / Basics.hs
Created January 30, 2016 19:34
TypeRep tomfoolery
{-# LANGUAGE TypeOperators, TypeFamilies, TypeApplications,
ExplicitForAll, ScopedTypeVariables, GADTs, TypeFamilyDependencies,
TypeInType, ConstraintKinds, UndecidableInstances,
FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies,
FlexibleContexts, StandaloneDeriving, InstanceSigs #-}
module Basics where
import Data.Type.Bool
import Data.Type.Equality
@DmitrySoshnikov
DmitrySoshnikov / s-expression-parser.js
Last active October 9, 2023 05:59
S-expression parser
/**
* S-expression parser
*
* Recursive descent parser of a simplified sub-set of s-expressions.
*
* NOTE: the format of the programs is used in the "Essentials of interpretation"
* course: https://github.com/DmitrySoshnikov/Essentials-of-interpretation
*
* Grammar:
*