Skip to content

Instantly share code, notes, and snippets.

@iximeow
iximeow / gist:019d1ce90d13836e0d7e
Created August 20, 2014 17:53
Playing with Rattler
#! /usr/bin/env ruby
require 'rattler'
class Test < Rattler::Runtime::ExtendedPackratParser
grammar %{
%whitespace BLANK*
start <- ext? components
@iximeow
iximeow / gist:6fa2f055034cac592259
Last active August 29, 2015 14:08
example of ixee UI element renderer code
public interface UIGenericElementRenderer<T extends glEEngine> {
public void unsafeDraw(UIElement elem, T engine);
}
public abstract class UIElementRenderer<T extends glEEngine, U extends UIElement> implements UIGenericElementRenderer<T> {
Class<U> myClass;
public UIElementRenderer(Class<U> rendereeClass) {
myClass = rendereeClass;
}
@iximeow
iximeow / gist:ce7d7eee5f53e3bda7c1
Last active August 29, 2015 14:09
SCALAAAAAA
implicit val byteOps: BitOps[Byte] = new BitOps[Byte] {
def >>>(t: Byte, x: Int): Byte = (t >>> x).toByte
def |(a: Byte, b: Byte): Byte = (a | b).toByte
def &(a: Byte, b: Byte): Byte = (a & b).toByte
//Need to put this in an `ArithmeticOps` or something, but this is ok for now
def +(a: Byte, b: Byte): Byte = (a + b).toByte
}
implicit class WithBitOpts[T : BitOps](x: T) {
def >>>(b: Int): T = implicitly[BitOps[T]].>>>(x, b)
@iximeow
iximeow / keybase.md
Created March 7, 2015 02:49
keybase.md

Keybase proof

I hereby claim:

  • I am a-wortman on github.
  • I am iximeow (https://keybase.io/iximeow) on keybase.
  • I have a public key whose fingerprint is 4DFE 1A27 B8E0 9198 755B 339F BDA6 8873 AF27 D00E

To claim this, I am signing this object:

import Data.List.Split
euler :: [[Int]] -> Int
euler a = head (head (collapse a))
collapse :: [[Int]] -> [[Int]]
collapse a = if length a > 1 then
collapse ((init (init a)) ++ [euler18max (last a) (last (init a))]) else a
--We ALWAYS want b to be one larger than a
trait Lazy[T] {
def value: T
def map[U](f: T => U): Lazy[U]
def flatten[U](implicit lazyConv: (=> T) => Lazy[U]): Lazy[U]
def flatMap[U](f: T => Lazy[U]): Lazy[U]
}
object Lazy {
implicit def lazyIdentity[A]: (=> Lazy[A]) => Lazy[A] = (old) => Lazy { old.value }
@iximeow
iximeow / gist:7a924996f9aa36b364a0
Created April 4, 2015 05:12
shapeless wizardry
object foo extends App {
case class Elem(a: Int, b: String, c: Int)
val l = Elem(1, "asf", 2)
trait R[T] {
def r(x: T): T
}
object defaultConvs extends Poly1 {
@iximeow
iximeow / gist:537770a522327358ea73
Last active August 29, 2015 14:19
I'm a bad person
package net.iximeow
import scala.slick.driver.SQLiteDriver.simple._
package object slick {
var instanceNum = 0;
def table(args: String*) = {
val xs = args.toSeq
var str = ""
str += s"class T${instanceNum}(tag: Tag) extends Table[(${xs.mkString(", ")})](tag, ${'"'}t${instanceNum}${'"'}) {"
@iximeow
iximeow / messy.rs
Last active September 6, 2015 20:29
high quality rust: beware
fn main() {
let x: &Expr<&ValT> = &Unit::<&ValT> {
expr: &IntValue { size: 5 }
};
}
trait ValT {}
trait Expr<T> {}
@iximeow
iximeow / ouch.scala
Created September 9, 2015 21:40
restricting Spray api response types
// Wanted to ensure complete() was only called with a certain response type, to give guarantees about api response structure
// (no accidental "returned a string when it should be json!" or "didn't actually give a body when I should have")
trait CustomRouteDirectives extends spray.routing.directives.RouteDirectives {
import spray.httpx.marshalling.ToResponseMarshallable
import spray.httpx.marshalling.ToResponseMarshallable.{isMarshallable => _}
import spray.httpx.marshalling.ToResponseMarshaller
import spray.httpx.marshalling.ToResponseMarshaller.{
eitherMarshaller,
futureMarshaller,
liftMarshaller,