Skip to content

Instantly share code, notes, and snippets.

View bitemyapp's full-sized avatar
🐺
aroo

Chris A. bitemyapp

🐺
aroo
View GitHub Profile
@DallasC
DallasC / linfa-eco.md
Created December 11, 2019 03:23
Rust AI Algorithm Ecosystem

Interesting general purpose crates to consider

peroxide

Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with farmiliar syntax

Bindings

faiss

Rust language bindings for Faiss, the state-of-the-art vector search and clustering library.

liblinear

Rust bindings for the liblinear C/C++ library. Provides a thin (but rustic) wrapper around the original C-interface exposed by the library.

@ekmett
ekmett / QC.hs
Created March 8, 2018 19:44
Using Quantified Constraints for Optics -- untypechecked (no compiler available)
{-# language TypeInType, QuantifiedConstraints, ConstraintKinds, RankNTypes, UndecidableInstances, MultiParamTypeClasses, TypeFamilies, KindSignatures #-}
module QC where
import Data.Constraint
import Data.Functor.Contravariant
import Data.Kind
import Data.Profunctor
type C = (Type -> Type) -> (Type -> Type -> Type) -> Constraint
@parsonsmatt
parsonsmatt / haskell-app-layers.md
Created December 11, 2017 15:48
A basic draft of a future blog post

The question of "How do I design my application in Haskell?" comes up a lot. There's a bunch of perspectives and choices, so it makes sense that it's difficult to choose just one. Do I use plain monad transformers, mtl, just pass the parameters manually and use IO for everything, the ReaderT design pattern, free monads, freer monads, some other kind of algebraic effect system?!

The answer is: why not both/all?

Lately, I've been centering on a n application design architecture with roughly three layers:

Layer 1:

newtype AppT m a = AppT { unAppT :: ReaderT YourStuff m a } deriving ............ The ReaderT Design Pattern, essentially. This is what everything gets boiled down to, and what everything eventually gets interpreted in. This type is the backbone of your app. For some components, you carry around some info/state (consider [MonadMetrics](https://hackage

@wmakley
wmakley / elm_handlers.js
Last active January 2, 2020 17:49
jQuery-based utilities for things that are hard to do in Elm. Modify as desired. It is used in a project that already depends on jQuery, but it only really needs jQuery for attaching event handlers to the app container, and normalizing key press events.
/*
JSCmd.elm
==========
port module JSCmd exposing (..)
port focus : String -> Cmd msg
#![cfg_attr(any(target_os = "ios", target_os = "android"), no_main]
fn main() {
main2();
}
#[cfg(any(target_os = "ios", target_os = "android"))]
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn SDL_main() -> i32 {

Where you able to produce a binary directly from the Rust build tools that you could submit to the app/play store?


Not quite, but I tried to get as close to that as was reasonably possible. Alas, things ended up a little convoluted.

For iOS, I have a nearly empty Xcode project with a build script that copies my cargo produced executable into the .app that Xcode generates (before Xcode signs it). The build script also uses lipo to merge the executables for each architecture I’m targeting (e.g. armv7 and aarch64 for non-simulator devices) into a single, universal binary.

On top of that, there are various iOS-y things that need to happen before my application’s main method is called. SDL2 provides the Objective-C code that does all of that. In a C or C++ game, SDL2 renames main to SDL_main, and then [inserts its own mai

@chrisdone
chrisdone / Parsing.md
Last active February 9, 2022 11:50
Good parser messages with Parsec

Intro

I've been working on a parser for a Haskell-like syntax called Duet. In the implementation I've taken particular care to make an awesome tokenizer and parser that is super helpful to learners.

Jasper Van der Jeugt made a talk about producing good error messages recently, which coincides nicely with my parallel work on this. So I thought I'd also share my

@KodrAus
KodrAus / Profile Rust on Linux.md
Last active November 14, 2023 17:19
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

@snoyberg
snoyberg / all-cabal-tool.yaml
Created September 26, 2016 05:12
Kubernetes files for Hackage mirroring
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: all-cabal-tool
labels:
app: all-cabal-tool
spec:
replicas: 1
minReadySeconds: 5
template:
@snoyberg
snoyberg / pid1.hs
Created September 25, 2016 16:07
A Haskell pid1. Work in progress, needs more testing!
-- This is a valid PID 1 process in Haskell, intended as a Docker
-- entrypoint. It will handle reaping orphans and handling TERM and
-- INT signals. This is a work in progress, please do not use it in
-- production!
{-# OPTIONS_GHC -Wall -Werror #-}
import Control.Concurrent (forkIO, newEmptyMVar, takeMVar, threadDelay,
tryPutMVar)
import Control.Exception (assert, catch, throwIO)
import Control.Monad (forever, void)