Skip to content

Instantly share code, notes, and snippets.

View evanchooly's full-sized avatar

Justin Lee evanchooly

View GitHub Profile
@evanchooly
evanchooly / baz.mirah
Created April 26, 2011 17:29 — forked from railsfactory/baz.mirah
mirah import example
#in bar folder
class Bar
class Baz
def hello
puts "hello from Baz"
end
end
end
@evanchooly
evanchooly / gist:4009860
Created November 4, 2012 02:27
ngrep samples
#sudo ngrep -d lo0 -q -W byline port ${PORT}
sudo ngrep -e -x -q port ${PORT}
package utils
import play.GlobalSettings
import com.google.inject.Injector
class GuiceGlobalSettings extends GlobalSettings {
var injector: Injector
override def onStart(application: play.Application) {
@evanchooly
evanchooly / gist:6062704
Created July 23, 2013 14:18
optional parameters
public void something(X x, Y y) {
something(x, y, someDefaultValue);
}
public void something(X x, Y y, SomeObject object) {
// do work
}
// vs
#! /bin/sh
M=META-INF/MANIFEST.MF
mkdir tmp
cd tmp
cp ../$1 .
JAR=$1
jar xf ${JAR}
function pr() {
if [ $# -lt 1 ]
then
echo "Error! Missing Pull Request ID #."
else
git fetch origin refs/pull/$1/head:pull-request-$1;
git checkout pull-request-$1;
fi
}
### Keybase proof
I hereby claim:
* I am evanchooly on github.
* I am evanchooly (https://keybase.io/evanchooly) on keybase.
* I have a public key whose fingerprint is F6ED 714C AE5E 04DA 72EB AF52 B50B 4733 6F36 116A
To claim this, I am signing this object:
public class WriteConcernTest {
public static void main(String[] args) throws InterruptedException {
MongoClient client = MongoClients.create();
System.out.println(client.getSettings().getWriteConcern());
client.getDatabase("test").getCollection("writeConcernTest").insertOne(new Document(), (result, t) -> System.out.println("DONE!"));
Thread.sleep(Long.MAX_VALUE);
}
MongoClient client = MongoClients.create(MongoClientSettings.builder()
.clusterSettings(ClusterSettings.builder().hosts(Collections.singletonList(new ServerAddress("localhost"))).build())
.writeConcern(WriteConcern.UNACKNOWLEDGED).build());
System.out.println(client.getSettings().getWriteConcern());
client.getDatabase("test").getCollection("writeConcernTest").insertOne(new Document(), (result, t) -> System.out.println("DONE!"));
Thread.sleep(Long.MAX_VALUE);
@evanchooly
evanchooly / IntegerListToArray.java
Created July 7, 2016 13:54
"how do I cast[sic] ArrayList<Integer> to int[] ? I've found toArray can only convert into Integer[]"
list.stream().mapToInt(i -> i.intValue()).toArray()