Skip to content

Instantly share code, notes, and snippets.

View lambdaknight's full-sized avatar

Turing Eret lambdaknight

View GitHub Profile
@lambdaknight
lambdaknight / gist:9061411
Created February 17, 2014 23:29
PriorityDeque
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 February 27, 2014 22:08
Macro for Adding Mixin to Classes
//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 April 4, 2014 20:03
Lens-like Access to Dictionary-like Object
{-# 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 / gist:5273810
Created March 29, 2013 21:32
Redirection of heredoc in zsh
(
cat << FOO
Some text here
Some more text
Yet some more text.
FOO
) > some_file
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;
@lambdaknight
lambdaknight / gist:6166631
Created August 6, 2013 17:30
Comment Switch!
/* <---- Add extra / on this line to uncomment first block and comment second block!
Function1();
/*/
Function2();
//*/
//*
Function1();
/*/
Function2();
@lambdaknight
lambdaknight / gist:7378549
Created November 8, 2013 22:16
Attributes With Path-Dependent Types
trait AttributeName { self =>
type AttributeType
def of(value : AttributeType) : Attribute = new Attribute {
type Name = self.type
val Value = value
}
}
trait Attribute {
@lambdaknight
lambdaknight / gist:8465187
Created January 16, 2014 23:01
Zipper Tree ?
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 = []}]}
@lambdaknight
lambdaknight / enumish.scala
Created February 17, 2016 17:49
Enumish Macros: Macro Annotation For Generating an Enum-ish Object
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 December 28, 2020 14:29
Remove Sponsored Facebook Elements
// ==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