Skip to content

Instantly share code, notes, and snippets.

@nlinker
nlinker / playground.rs
Last active October 8, 2017 09:11 — forked from anonymous/playground.rs
BWAPI idiomatic Rust binding variant 2 from Migi
use std::marker::PhantomData;
use std::cell::Cell;
pub struct Game<'g> {
// Putting the lifetime 'g into a PhantomData<Cell<&'g ()>> instead of a
// PhantomData<&'g ()> makes 'g invariant instead of covariant.
// I don't know if that's necessary here, but better be safe than sorry.
// See https://doc.rust-lang.org/nomicon/subtyping.html for more info.
phantom: PhantomData<Cell<&'g ()>>,
}
@nlinker
nlinker / playground.rs
Last active September 23, 2017 21:28 — forked from anonymous/playground.rs
BWAPI idiomatic bindings, solution from Migi
#![feature(optin_builtin_traits)]
mod userspace {
use unit::Unit;
use session::{Ai, DataTrait, Session};
#[derive(Debug)]
struct MyAi<'a> {
units: Vec<&'a mut Unit>
}
@nlinker
nlinker / playground.rs
Created June 30, 2017 05:07 — forked from anonymous/playground.rs
Rust code shared from the playground
#![feature(optin_builtin_traits)]
mod userspace {
use unit::Unit;
use session::{Ai, DataTrait, Session};
#[derive(Debug)]
struct MyAi();
#[derive(Debug)]
@nlinker
nlinker / First.hs
Created March 25, 2017 04:39 — forked from cblp/First.hs
First as Applicative
{-# OPTIONS -Wall -Werror #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
import Control.Applicative ((<|>))
import Control.Monad (void)
import Test.QuickCheck
import Text.Show.Functions ()
@nlinker
nlinker / XPS-15 9560 Getting Nvidia To Work on KDE Neon
Created March 11, 2017 16:50 — forked from whizzzkid/XPS-15 9560 Getting Nvidia To Work on KDE Neon
Making Nvidia Drivers + CUDA 8 + Bumblebee work together on XPS 15 Early 2017 9560 kabylake.
# Update to 4.9 kernel do not delete the old kernel as it will be your failsafe if something happens to this one
# Install KabyLake graphics patches
cd /tmp;
wget https://01.org/sites/default/files/downloads/intelr-graphics-linux/kbldmcver101.tar.bz2;
tar xjvf kbldmcver101.tar.bz2; cd kbl_dmc_ver1_01/; sudo ./install.sh
cd /tmp;
wget https://01.org/sites/default/files/downloads/intelr-graphics-linux/kblgucver914.tar.gz;
tar xvzf kblgucver914.tar.gz; cd firmware/kbl/guc/kbl_guc_ver/; sudo ./install.sh
@nlinker
nlinker / gist:fa195774d0fda9f12e8ca11620145219
Created March 2, 2017 18:09 — forked from avieth/gist:334201aa341d9a00c7fc
Interpreting Free Monads of Functor Sums
Interpreting Free Monads of Functor Sums
========================================
This text deals with a way to compose certain kinds of monads, thereby mixing
their capabilities. It is a literate Haskell file, so let's begin with a
bunch of noise.
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE FlexibleInstances #-}
> {-# LANGUAGE FlexibleContexts #-}
@nlinker
nlinker / freefrp.js
Created March 2, 2017 08:10 — forked from jpallari/freefrp.js
Free monad based thread simulation and FRP constructs written in JavaScript. http://stuff.lepovirta.org/r/freefrp/
// Free monad based thread simulation and FRP constructs written in JavaScript
// First, we need some way to express lazy values and actions.
// We can use zero-argument functions for this purpose: call the function and
// you get the value. We also need to compose lazy values/actions. For that
// we have bindLazy function. Lazy values are not expected to be pure
// in this program: evaluating a lazy value/action at different times can produce
// a different value.
Хм... Сложно согласиться с
> в Haskell монады -- это способ записать _императивный_ код в полностью декларативном языке.
Наверное если смотреть технически - то это верное высказывание.
Но оно скрывает суть. Скрывает смысл "пользы от монад".
Насколько я помню...
Монады - они и в Африке монады. В независимости от того какой язык - чисто декларативный/функциональный или нет.
@nlinker
nlinker / build.sbt
Created August 5, 2016 13:59 — forked from eed3si9n/build.sbt
Source dependency
lazy val scalaJson = ProjectRef(uri("git://github.com/mdedetrich/scala-json-ast.git#c5ee84"), "scalaJsonASTJVM")
lazy val root = (project in file(".")).
dependsOn(scalaJson).
settings(inThisBuild(List(
organization := "com.example",
scalaVersion := "2.11.8"
)),
name := "sourceDeps"
)