Skip to content

Instantly share code, notes, and snippets.

View armanbilge's full-sized avatar
😵
Declaring notification bankruptcy. If I forgot your PR please ping me!

Arman Bilge armanbilge

😵
Declaring notification bankruptcy. If I forgot your PR please ping me!
View GitHub Profile
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/udp.h>
#include <arpa/inet.h>
//> using scala "3.1.1"
//> using option "-Ykind-projector"
//> using lib "org.tpolecat::natchez-core::0.1.6"
import cats._
import cats.data._
import cats.effect.kernel._
import natchez._
// A rough approximation of Resource as a typeclass
import sys
import itertools as it
import random
cards = [1] + 5 * [1, 2, 3, 4, 5, 7, 8, 10, 11, 12, 'Sorry!']
shuffled = lambda x: random.sample(x, len(x))
deck = it.chain.from_iterable((shuffled(cards) for _ in it.count()))
for l in sys.stdin:
@armanbilge
armanbilge / Main.scala
Created September 15, 2016 08:26
Brainfuck interpreter in scala
package bf
import java.util.Scanner
import scala.annotation.tailrec
object Main extends App {
@tailrec
def f(p: List[Char], i: Int = 0, c: Vector[Int] = Vector.fill(10000)(0), st: List[List[Char]] = Nil, ex: List[Boolean] = List(true)): Unit = if (ex.head) p match { case Nil => case '+' :: pp => f(pp, i, c.updated(i, c(i) + 1), st, ex) case '-' :: pp => f(pp, i, c.updated(i, c(i) - 1), st, ex) case '>' :: pp => f(pp, i + 1, c, st, ex) case '<' :: pp => f(pp, i - 1, c, st, ex) case '.' :: pp => print(c(i).asInstanceOf[Char]); f(pp, i, c, st, ex) case ',' :: pp => f(pp, i, c.updated(i, new Scanner(System.in).nextByte().asInstanceOf[Int]), st, ex) case '[' :: pp => f(pp, i, c, p :: st, (c(i) != 0) :: ex) case ']' :: pp => f(st.head, i, c, st.tail, ex.tail) case _ :: pp => f(pp, i, c, st, ex) } else p match { case Nil => case '[' :: pp => f(pp, i, c, p :: st, false :: ex) case ']' :: pp => f(pp, i, c, st.tail, ex.tail) case _ :: pp => f(pp, i, c, st, ex) }

Keybase proof

I hereby claim:

  • I am armanbilge on github.
  • I am arman (https://keybase.io/arman) on keybase.
  • I have a public key ASCDQkGP1zR4y5DZ1GZ0dWzd770b0L3NjcZdIEqeApX7Pwo

To claim this, I am signing this object:

for y in {1952..2016}; do
wget --post-data "method=loadAwardeeList&awardYear=$y&awardType=A&action=Search" https://www.fastlane.nsf.gov/grfp/AwardeeList.do -O "awardees_$y.txt"
done
from functools import lru_cache
import itertools as it
from scipy.misc import comb
@lru_cache(None)
def f(k, n):
if k == 0:
return 0
return k ** n - sum(int(comb(k, i)) * f(i, n) for i in range(k))
@armanbilge
armanbilge / tree69.py
Last active May 13, 2016 03:23
A tree utility library for COMPSCI 369
"""
tree69.py
A tree utility library for COMPSCI 369.
"""
# The MIT License (MIT)
#
# Copyright (c) 2016 Arman Bilge and Stuart Bradley
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Arman Bilge
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
implicit def JetIsReal[T : IsReal : Semiring : ClassTag](implicit jd: JetDim) = new IsReal[Jet[T]] {
override def ceil(a: Jet[T]): Jet[T] = Jet(IsReal[T].ceil(a.real))
override def toDouble(a: Jet[T]): Double = IsReal[T].toDouble(a.real)
override def toReal(a: Jet[T]): Real = IsReal[T].toReal(a.real)
override def round(a: Jet[T]): Jet[T] = Jet(IsReal[T].round(a.real))