This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is what I did to revert a lot of changes I had made to a branch over a 2 week period, but still keep other commits that weren't mine. | |
git branch old-master | |
git reset <commitId> --hard | |
for i in `git log master..old-master | grep -v "Author: Ivan Meredith" |grep -B 1 Author |grep commit | awk '{print $2}'`|tail -r; do git cherry-pick $i;done | |
git push origin master --force | |
git push origin old-master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<disabledTestInjection>true</disabledTestInjection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val a = print("Hello ").pure[IO] | |
val b = println("World!").pure[IO] | |
println("Now printing HW") | |
a >|> b unsafePerformIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def instanceState(id: String)(implicit c: AWSEC2Client, region: String = null) = { | |
for { | |
instance <- c.getInstanceServices.describeInstancesInRegion(region, id).headOption | |
runningInstance <- instance.headOption | |
} yield runningInstance.getInstanceState | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def createContext = { | |
ContextBuilder.newBuilder(new AWSEC2ProviderMetadata) | |
.credentials("<>", "<>") | |
.buildView(classOf[AWSEC2ComputeServiceContext]) | |
.unwrap(classOf[RestContext[AWSEC2Client, AWSEC2AsyncClient]]) | |
} | |
implicit def syncApi = createContext.getApi | |
def createInstance(imageId: String, hwType: String, group: String, key: String)(implicit c: AWSEC2Client, region: String = null) = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def repeatWithIndex(field: play.api.data.Field, min: Int = 1)(f: (play.api.data.Field, Int) => Html) = { | |
(0 until math.max(if (field.indexes.isEmpty) 0 else field.indexes.max + 1, min)).map(i => f(field("[" + i + "]", i))) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> trait Functor[F[_]] { def a[A, B](b: A => B): F[A] => F[B]} | |
defined trait Functor | |
scala> object Test extends Functor[Option] { def a[A, B](b: A=>B) = (a: Option[A]) => a map b} | |
defined module Test | |
scala> Test.a((a: String) => a.length) | |
res8: (Option[String]) => Option[Int] = <function1> | |
scala> res8(Some("teSt")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Monad[IntS] { | |
def map[A, B](f: A => B) = (a: IntS[A]) => IntS((i: Int) => { | |
val res = a.k(i) | |
(res._1, f(res._2)) | |
}) | |
def flatMap[A, B](f: A => IntS[B]) = (a: IntS[A]) => IntS((i: Int) => { | |
val res = a.k(i) | |
f(res._2).k(i) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Monad[F[_], A] { | |
def map[B](f: A => B): F[B] | |
def flatMap[B](f: A => F[B]): F[B] | |
} | |
case class IntS[A](k: Int => (Int, A)) extends Monad[IntS, A] { | |
def map[B](f: A => B): IntS[B] = IntS((i: Int) => { | |
k(i) match { | |
case (s, a) => (s, f(a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum(f: Int => Int)(a: Int, b: Int): Int = { | |
if (a > b) 0 else f(a) + sum(f)(a + 1, b) | |
} | |
def sumInts = sum(x => x) _ |