Skip to content

Instantly share code, notes, and snippets.

@ghais
ghais / gist:3989200
Created October 31, 2012 19:15
Is Hell exothermic or endothermic
The following is supposedly an actual question given on a University of Washington chemistry mid-term. The answer by one student was so
"profound" that the professor shared it with colleagues, via the Internet, which is, of course, why we now have the pleasure of enjoying it as well.
Is Hell exothermic (gives off heat) or endothermic (absorbs heat)?Most of the students wrote proofs of their beliefs using Boyle's Law (gas cools when it expands and heats when it is compressed) or some variant.
One student, however, wrote the following:
In short, methods on interfaces make programs conceptually more complex,
and don't do anything of use.
Interfaces are, at present, simply a declaration of required operations
that a type must permit for it to meet that interface.
This would change that, and:
1) Make so a method call on an interface is not essentially an
implementation-specific operation on the data in the interface.
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
/tmp/storm-0.7.1 # ./bin/storm jar storm-sta.1-SNAPSHOT-jar-with-dependencies.jar storm.starter.WordCountTopology 1
Running: java -client -Dstorm.home=/tmp/storm-0.7.1 -Dstorm.options= -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.jar=storm-sta.1-SNAPSHOT-jar-with-dependencies.jar -cp /tmp/storm-0.7.1/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar:/tmp/storm-0.7.1/storm-0.7.1.jar:/tmp/storm-0.7.1/lib/ring-core-0.3.10.jar:/tmp/storm-0.7.1/lib/curator-client-1.0.1.jar:/tmp/storm-0.7.1/lib/clojure-1.2.0.jar:/tmp/storm-0.7.1/lib/servlet-api-2.5.jar:/tmp/storm-0.7.1/lib/joda-time-1.6.jar:/tmp/storm-0.7.1/lib/zookeeper-3.3.3.jar:/tmp/storm-0.7.1/lib/jline-0.9.94.jar:/tmp/storm-0.7.1/lib/core.incubator-0.1.0.jar:/tmp/storm-0.7.1/lib/clojure-contrib-1.2.0.jar:/tmp/storm-0.7.1/lib/compojure-0.6.4.jar:/tmp/storm-0.7.1/lib/httpclient-4.1.1.jar:/tmp/storm-0.7.1/lib/commons-lang-2.5.jar:/tmp/storm-0.7.1/lib/json-simple-1.1.jar:/tmp/storm-0.7.1/lib/minlog-1.2.jar:/tmp/storm-0.7.1/lib/log4j-1.2.
KeyValue kv = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("24"), Bytes.toBytes("2"), Bytes.toBytes(7L));
Result result = new Result(new KeyValue[] { kv });
System.out.println(Bytes.toLong(result.getValue(Bytes.toBytes("2"), Bytes.toBytes("2"))));
class C {
protected var x = 0;
def incr: this.type = { x = x + 1; this }
}
class D extends C {
def decr: this.type = { x = x - 1; this } }
Then we can chain calls to the incr and decr method, as in val d = new D; d.incr.decr;
@ghais
ghais / compiler output
Created June 11, 2011 18:49
example.go
play.go:20: cannot use &b (type *Baz) as type Foo in function argument:
*Baz does not implement Foo (wrong type for FooBar method)
have FooBar(other *Baz)
want FooBar(other Foo)
@ghais
ghais / gist:1020833
Created June 11, 2011 18:46
example.go
package main
type Foo interface {
FooBar(other Foo)
}
func Bar(f Foo) {
f.FooBar(f)
}
> db.Test.insert({something:123, engagementResults:[{d:1}, {d:2}]});
> db.Test.find({d:1})
> db.Test.find({"engagementResults.d":1})
{ "_id" : ObjectId("4deecede6b5e82cdaf01663b"), "something" : 123, "engagementResults" : [ { "d" : 1 }, { "d" : 2 } ] }
>
@ghais
ghais / gist:1013594
Created June 8, 2011 01:19
CampaignResult.json
{
_id:"Some key",
deliveryDate: 1231312312312L,
engagementResults:[
{id_:1,
deliveryDate: 1L
},
{_id:2,
deliveryDate: 2L
}]