Skip to content

Instantly share code, notes, and snippets.

View bitonic's full-sized avatar
🍥
bottomless pit

Francesco Mazzoli bitonic

🍥
bottomless pit
View GitHub Profile
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RecordWildCards #-}
import Data.List (transpose)
data Forward a = Forward { _value :: !a, _grad :: !a }
deriving (Show, Eq)
lift :: Num a => a -> Forward a
lift a = Forward { _value = a, _grad = 0 }
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
#! /usr/bin/env bash
# Script to install NixOS from the Hetzner Cloud NixOS bootable ISO image.
# (tested with Hetzner's `NixOS 20.03 (amd64/minimal)` ISO image).
#
# This script wipes the disk of the server!
#
# Instructions:
#
# 1. Mount the above mentioned ISO image from the Hetzner Cloud GUI
@bitonic
bitonic / poly.ts
Created June 5, 2020 13:22
polygon cube intersection in threejs
function signNonZero(x: number): number {
return x < 0 ? -1 : 1;
}
function inClosedInterval(a: number, x: number, b: number): boolean {
return (x-a) * (x-b) <= 0;
}
function segContainsPoint(a: number, b: number, x: number): number {
return (b > x ? 1 : 0) - (a > x ? 1 : 0);
{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-}
-- Laungh ghci with -fobject-code to make the Fix/Tree trick work (thanks edwardk).
-- courtesy of hpc on #haskell
import Unsafe.Coerce
import Control.Monad.ST
toInteger :: Int -> Integer
isJust :: Maybe a -> Bool
null :: [a] -> Bool
@bitonic
bitonic / eigen-avx.c
Last active January 13, 2020 09:02
Repro for Eigen not using AVX operations
// Compiled with
//
// g++ -std=c++17 -march=native -O3 -I<path-to-eigen-master> eigen-avx.c -o eigen-avx
//
// Expected output:
//
// With size 8, normal_count: 0, packet4_count: 0, packet8_count: 1
// With size 9, normal_count: 1, packet4_count: 0, packet8_count: 1
//
// Actual output:
@bitonic
bitonic / AgdaBasics.agda
Created February 7, 2012 09:28
Agda tutorial
module AgdaBasics where
apply : (A : Set)(B : A → Set) → ((x : A) → B x) → (a : A) → B a
apply A B f a = f a
_∘_ : {A : Set}{B : A → Set}{C : (x : A) → B x → Set}
(f : {x : A}(y : B x) → C x y)(g : (x : A) → B x)
(x : A) → C x (g x)
(f ∘ g) x = f (g x)
@bitonic
bitonic / readme.txt
Created December 13, 2018 21:30
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@bitonic
bitonic / francesco.el
Created June 22, 2012 12:58
My emacs config
;;; ===========================================================================
;;; Francesco's emacs config, <f@mazzo.li>
;;; Packages needed: paredit-el, wl-beta, auto-complete-el, haskell-mode,
;;; erlang-mode, w3m-el, bbdb, slime, elib, cscope-el
;;; Non-debian packages: distel, undo-tree, highlight-parentheses, agda2,
;;; sicstus, ghc-mod
;;; Additional dirs
(add-to-list 'load-path "~/.emacs.d/site-lisp/distel")
(add-to-list 'load-path "~/.emacs.d/site-lisp/sicstus")
import GHC.Generics
import Data.Kind
import qualified Data.Vector as V
import qualified Data.HashMap.Strict as HMS
import qualified Data.Map.Strict as Map
import Data.Hashable (Hashable)
type family WebApiType a :: *