Skip to content

Instantly share code, notes, and snippets.

@stuhood
stuhood / gist:988452
Created May 24, 2011 09:57
XOR Metric Example
/**
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
// strongly connected component:
digraph {
0 [label="@rule(pants.engine.internals.build_files:152:addresses_with_origins_from_address_specs(AddressSpecs, GlobalOptions, AddressSpecsFilter) -> AddressesWithOrigins, gets=[Get(Address, AddressInput), Get(TargetAdaptor, Address), Get(UnexpandedTargets, Addresses), Get(Snapshot, PathGlobs), Get(AddressFamily, Dir)])"]
1 [label="@rule(pants.engine.internals.graph:424:addresses_with_origins_from_filesystem_specs(FilesystemSpecs, GlobalOptions) -> AddressesWithOrigins, gets=[Get(Snapshot, PathGlobs), Get(Owners, OwnersRequest)])"]
2 [label="@rule(pants.engine.internals.graph:470:resolve_addresses_with_origins(Specs) -> AddressesWithOrigins, gets=[Get(AddressesWithOrigins, AddressSpecs), Get(AddressesWithOrigins, FilesystemSpecs)])"]
3 [label="@rule(pants.engine.internals.graph:172:resolve_unexpanded_targets(Addresses) -> UnexpandedTargets, gets=[Get(WrappedTarget, Address)])"]
4 [label="@rule(pants.engine.internals.build_files:221:strip_address_or
// strongly connected component:
digraph {
0 [label="NodeIndex(51): @rule(pants.engine.process:219:fallible_to_exec_result_or_raise(FallibleProcessResult, ProductDescription) -> ProcessResult)"]
1 [label="NodeIndex(66): @rule(<intrinsic>(MultiPlatformProcess, Platform) -> FallibleProcessResultWithPlatform)"]
2 [label="NodeIndex(83): @rule(pants.backend.python.rules.pex_environment:129:find_pex_python(PythonSetup, PexRuntimeEnvironment, SubprocessEnvironment) -> PexEnvironment, gets=[Get(BinaryPaths, BinaryPathRequest)])"]
3 [label="NodeIndex(107): @rule(pants.engine.process:237:remove_platform_information(FallibleProcessResultWithPlatform) -> FallibleProcessResult)"]
4 [label="NodeIndex(139): @rule(pants.engine.process:208:get_multi_platform_request_description(MultiPlatformProcess) -> ProductDescription)"]
5 [label="NodeIndex(170): @rule(pants.core.util_rules.external_tool:171:download_external_tool(ExternalToolRequest) -> DownloadedExternalTool, gets=[Get(Digest, DownloadFile), Get(E
@rule(Logger, [Workunit])
def logger(workunit):
# Maybe we don't need both `Logger` and `Workunit`?
..
@rule(Classpath, [Logger, Target])
def compile_some_stuff(logger, target):
..
@console_rule(Compile, [Specs])
[info] Non-compiled module 'compiler-interface' for Scala 2.10.6. Compiling...
/var/folders/tc/kq93y4pd5jn6gy3pfzd2zd5h0000gn/T/sbt_2a44fe22/xsbt/ClassName.scala:23: error: not found: value enteringPhase
enteringPhase(currentRun.flattenPhase.next) { s fullName separator }
^
/var/folders/tc/kq93y4pd5jn6gy3pfzd2zd5h0000gn/T/sbt_2a44fe22/xsbt/ClassName.scala:73: error: not found: value enteringPhase
enteringPhase(currentRun.picklerPhase.next) {
^
/var/folders/tc/kq93y4pd5jn6gy3pfzd2zd5h0000gn/T/sbt_2a44fe22/xsbt/ClassName.scala:83: error: not found: value enteringPhase
enteringPhase(currentRun.picklerPhase.next) { s.fullNameAsName('.') }
try {
`(╯°□°)╯︵ ┻━┻`
} catch {
`┬─┬ ノ( ゜-゜ノ)`
}
def `┬─┬ ノ( ゜-゜ノ)`: PartialFunction[Throwable,Any] = {
case e => println("caught " + e)
}
@stuhood
stuhood / gist:8425008
Last active January 3, 2016 06:49
A sketch of how you'd implement an IterableStore for Redis, with a *private* Cursor type.
class RedisStore[K,V] extends IterableStore[K,V] {
private type Cursor = ???
private val InitialCursor: Cursor = ???
/** Get the next batch from Redis, and return a new Cursor. */
private def getBatch(cursor: Cursor): Future[(Seq[(K,V)],Cursor)] = ???
private def getAllHelper(cursor: Cursor): Future[Spool[Seq[(K,V)]]] =
getBatch(cursor).map {
case (batch, nextCursor) => batch *:: getAllHelper(nextCursor)
@stuhood
stuhood / StringTest.scala
Last active December 24, 2015 02:59
(pretend this is using caliper) Scala compiler version 2.10.2 -- Copyright 2002-2013, LAMP/EPFL java version "1.7.0_17" Java(TM) SE Runtime Environment (build 1.7.0_17-b02) Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
/**
* $ for i in javabuilder javaformat javaconcat scalaformat scalaconcat scalainterp scalabuilder; do
* $ echo $i; rm -f *.class ; javac *.java && scalac -classpath . *.scala && scala -cp . StringTest $i
* $ done
*
* javabuilder
* Time after for loop 3500
* javaformat
* Time after for loop 85845
* javaconcat
@stuhood
stuhood / assert.java
Created August 23, 2011 22:57
CliTest Assertion
[junit] WARN 15:50:02,614 Generated random token Token(bytes[ce229b8ce46ec77dc8763200c4ac47d6]). Random tokens will result in an unbalanced ring; see http://wiki.apache.org/cassandra/Operations
[junit] ERROR 15:50:03,369 Fatal exception in thread Thread[ScheduledTasks:1,5,main]
[junit] java.lang.AssertionError
[junit] at org.apache.cassandra.service.GCInspector.logGCResults(GCInspector.java:110)
[junit] at org.apache.cassandra.service.GCInspector.access$000(GCInspector.java:41)
[junit] at org.apache.cassandra.service.GCInspector$1.run(GCInspector.java:85)
[junit] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
[junit] at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
[junit] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
[junit] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
@stuhood
stuhood / gist:988443
Created May 24, 2011 09:51
XOR Metric Example Buckets
Localhost: /68.27.46.62
Random addresses from each bucket:
Peers in bin 1
at 0x6a06d0d8: /46.29.254.230
at 0x6a301c9a: /46.43.50.164
at 0x5b0a180a: /31.17.54.52
at 0x5c277b3d: /24.60.85.3
at 0x5c131d3b: /24.8.51.5
at 0x56552d91: /18.78.3.175
at 0x5c017525: /24.26.91.27