Skip to content

Instantly share code, notes, and snippets.

Avatar

Turing Eret lambdaknight

View GitHub Profile
@lambdaknight
lambdaknight / gist:5273810
Created Mar 29, 2013
Redirection of heredoc in zsh
View gist:5273810
(
cat << FOO
Some text here
Some more text
Yet some more text.
FOO
) > some_file
View gist:5548767
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public sealed class Maybe<T>
{
private readonly bool _hasValue;
private readonly T _value;
View gist:6166631
/* <---- Add extra / on this line to uncomment first block and comment second block!
Function1();
/*/
Function2();
//*/
//*
Function1();
/*/
Function2();
@lambdaknight
lambdaknight / gist:7378549
Created Nov 8, 2013
Attributes With Path-Dependent Types
View gist:7378549
trait AttributeName { self =>
type AttributeType
def of(value : AttributeType) : Attribute = new Attribute {
type Name = self.type
val Value = value
}
}
trait Attribute {
View gist:8465187
tree :: Tree Int
tree = Node 1 [ Node 2 [], Node 3 [] ]
test = zipper tree
& downward branches
& withins traverse
<&> downward root
<&> focus %~ (\x -> x + 10)
<&> rezip
-- Node {rootLabel = 1, subForest = [Node {rootLabel = 12, subForest = []},Node {rootLabel = 3, subForest = []}]}
View gist:9061411
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace us.lambdacalcul.collections
{
public class PriorityDeque<T, P>
{
@lambdaknight
lambdaknight / gist:9260629
Created Feb 27, 2014
Macro for Adding Mixin to Classes
View gist:9260629
//SomeTraits.scala
trait Foo {
def someNumbers: List[Int]
def getNumbers : List[Int] = someNumbers
}
trait FilteredFoo extends Foo {
def numberFilter : Int => Boolean
@lambdaknight
lambdaknight / gist:9982115
Created Apr 4, 2014
Lens-like Access to Dictionary-like Object
View gist:9982115
{-# LANGUAGE RankNTypes #-}
module AList where
import Control.Lens
type AList t = [(String, t)]
alistGet :: String -> AList t -> Maybe t
alistGet key ((k,v):xs)
@lambdaknight
lambdaknight / enumish.scala
Created Feb 17, 2016
Enumish Macros: Macro Annotation For Generating an Enum-ish Object
View enumish.scala
import scala.annotation.{StaticAnnotation, compileTimeOnly}
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
trait EnumishValue extends Ordered[EnumishValue] with java.lang.Comparable[EnumishValue] {
def id: Int
def compare(that: EnumishValue) = this.id - that.id
}
@compileTimeOnly("enable macro paradise to expand macro annotations")
@lambdaknight
lambdaknight / kill_sponsored_facebook.user.js
Created Dec 28, 2020
Remove Sponsored Facebook Elements
View kill_sponsored_facebook.user.js
// ==UserScript==
// @name Remove Sponsored Facebook Elements
// @description Remove sponsored items from feed.
// @author Turing Eret
// @namespace us.lambdacalcul
// @version 0.1
// @copyright Copyright © 2020 Turing Eret
// @license MIT
// @match https://*.facebook.com/*
// @grant none