An introduction to curl using GitHub's API
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
| # Credit http://stackoverflow.com/a/2514279 | |
| for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r |
| // http://stackoverflow.com/questions/8104846/chart-of-ienumerable-linq-equivalents-in-scala | |
| xs.Aggregate(accumFunc) -> xs.reduceLeft(accumFunc) | |
| xs.Aggregate(seed, accumFunc) -> xs.foldLeft(seed)(accumFunc) | |
| xs.Aggregate(seed, accumFunc, trans) -> trans(xs.foldLeft(seed)(accumFunc)) | |
| xs.All(pred) -> xs.forall(pred) | |
| xs.Any() -> xs.nonEmpty | |
| xs.Any(pred) -> xs.exists(pred) | |
| xs.AsEnumerable() -> xs.asTraversable // roughly | |
| xs.Average() -> xs.sum / xs.length |
| #!/bin/bash | |
| set -u | |
| # Clones and softlinks a git repo, _if needed_. | |
| # Summary of steps: | |
| # 1. Checks that the provided repo is valid (SSH or HTTP) | |
| # 2. Compares local and remote commit to see if there is a new version | |
| # 3. Clones the remote commit in local, adding -<timestamp>-<commit> to the folder name | |
| # 4. Deletes .git directory of the cloned repo |
| # Based on patent https://www.google.com/patents/US7251579 | |
| # Not responsible if you use this for anything other than personal use | |
| from math import sqrt | |
| def realfeel(W, #windspeed mph | |
| A, #pressure mb | |
| T, # temperature F | |
| UV, # UV Index | |
| D, # Dew Point F | |
| P2, # preciptation Factor from 0-5 |
any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
never is assignable to any, and any is assignable to anything at all.any & AnyTypeExpression = any, any | AnyTypeExpression = anyunknown: proper, well-behaved [top type]
unknown. unknown is only assignable to itself (unknown) and any.unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknownany whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.| //This implementation is a porting of naive continuation monad in Haskell in "All About Monads" pages. | |
| class Cont[R, +A](val runCont: (A => R) => R) { | |
| def map[B](f: A => B): Cont[R, B] = { | |
| new Cont[R, B](k => runCont(a => Cont.ret[R, B](f(a)).runCont(k))) | |
| } | |
| def flatMap[B](f: A => Cont[R, B]) :Cont[R, B] = { | |
| new Cont[R, B](k => runCont(a => f(a).runCont(k))) | |
| } | |
| } |
| case class M[+A](in: (A => Any) => Any); | |
| def unit[A](x: A) = M { k: (A => Any) => k(x) } | |
| def bind[A, B](m: M[A], f: A => M[B]): M[B] = | |
| M { k: (B => Any) => | |
| m.in { x: A => | |
| f(x).in(k) | |
| } | |
| } |
| object Main extends App { | |
| trait Functor[F[_]] { | |
| def map[A, B](fa: F[A])(f: A => B): F[B] | |
| } | |
| sealed trait Nat[A] | |
| final case class Z[A]() extends Nat[A] | |
| final case class S[A](a: A) extends Nat[A] |