Skip to content

Instantly share code, notes, and snippets.

private void readFrame(
byte[] buffer, int frameLength, int leftToRead, Ref<bool> continueReading,
Act<Try<Messages.Messages.FromServer>> callback
) {
Log.debug(string.Format(
"Entering #readFrame(frameLength={0}, leftToRead={1})", frameLength, leftToRead
));
var stream = tcp.GetStream();
stream.BeginRead(buffer, frameLength - leftToRead, leftToRead, ar => {
var bytesRead = stream.EndRead(ar);
@arturaz
arturaz / gist:a533ea7e832a8132d791
Created January 7, 2015 20:31
cue file extractor
#!/usr/bin/env ruby
$tracks = []
class Track
attr_accessor :no, :hours, :minutes, :seconds, :performer, :song_name
def initialize(no, hours, minutes, seconds, title)
@no, @hours, @minutes, @seconds = no, hours, minutes, seconds
split_title = title.split("-", 2)
#!/usr/bin/env ruby
$tracks = []
class Track
attr_accessor :no, :hours, :minutes, :seconds, :performer, :song_name
def initialize(no, hours, minutes, seconds, title)
@no, @hours, @minutes, @seconds = no, hours, minutes, seconds
split_title = title.split("-", 2)
def moveAttack[A <: MovableFighter](
world: World, unit: A,
target: SearchRes[OwnedObj], strict: Boolean=true
)(implicit ev: A#Self =:= A): Result[A] = {
moveAndThen(world, unit, target.path, strict) { case (newWorld, movedUnit) =>
movedUnit.attackWS(target.value, newWorld).right.map(_.map {
case (w, u) => (w, u)
})
}
}
import sbt.Keys._
name := "TBS Game"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.sonatypeRepo("releases")
resolvers += Resolver.sonatypeRepo("snapshots")
package app.models.game.world
import java.util.UUID
import app.models.game._
import app.models.game.world.buildings._
import app.models.game.world.props.{ExtractionSpeed, AsteroidImpl, PropImpl}
import app.models.game.world.units._
import utils.IdObj
object SafeFizzBuzz extends scalaz.effect.SafeApp {
import scalaz._
import scalaz.effect._
import scalaz.std.string._
override def run(args: ImmutableArray[String]): IO[Unit] = {
def int2answer(i: Int) =
if (i % 3 == 0 && i % 5 == 0) Some("fizzbuzz")
else if (i % 3 == 0) Some("fizz")
else if (i % 5 == 0) Some("buzz")
response.ids.foldLeft(
Task.now(Vector.empty[ApiQuery.OrderResponse])
) { (task, id) =>
for {
responses <- task
response <- ApiQuery.Order(id).request(cfg.baseUri, cfg.websiteRetries)
} yield responses :+ response
}
------ laurynas-tretjakovas-try-2/stupid/src/main/scala/stupid/Card.scala ------
index 6d19063..51a8095 100755
@@ -3,11 +3,13 @@ package stupid
import stupid.rank.Rank
import stupid.suite.Suite
-case class Card(suite: Suite, rank: Rank) extends Ordered[Card] {
- override def compare(that: Card): Int = Ordering.by[Card, (Rank, Suite)] { c => (c.rank, c.suite) }.compare(this, that)
-}
+case class Card(suite: Suite, rank: Rank)
@arturaz
arturaz / code
Last active August 29, 2015 14:20
- name: link nebula44 server munin plugins
file: src={{ home }}/nebula-server/current/script/munin-plugins/{{ item.src }}
dest=/etc/munin/plugins/nebula44_{{ item.dest }}
state=link
with_items: "{{
res = ['metal', 'energy', 'zetium', 'creds']
kinds = ['rates', 'counts']
[
{
'src': 'market_.rb',