Skip to content

Instantly share code, notes, and snippets.

@xhanin
xhanin / plugin.groovy
Created February 13, 2013 22:16
Insert MongoDB ObjectId IntellijEval plugin
import com.intellij.openapi.actionSystem.AnActionEvent
import static intellijeval.PluginUtil.*
import org.bson.types.*;
// add-to-classpath $HOME/.m2/repository/org/mongodb/mongo-java-driver/2.10.1/mongo-java-driver-2.10.1.jar
registerAction("InsertMongoObjectId", "alt shift O") { AnActionEvent event ->
runDocumentWriteAction(event.project) {
currentEditorIn(event.project).with {
def offset = caretModel.offset
@xhanin
xhanin / Server.java
Created August 14, 2012 09:50
Vert.x with Java 8 Lambda
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.deploy.Verticle;
public class Server extends Verticle {
@Override
public void start() throws Exception {
vertx.createHttpServer().requestHandler((HttpServerRequest req) -> {
String file = req.path.equals("/") ? "index.html" : req.path;
req.response.sendFile(file);
}).listen(8086);
@xhanin
xhanin / Download.groovy
Created August 13, 2012 19:48
Download file with Vert.x (not working with vert.x 1.2.3)
import static org.vertx.groovy.core.streams.Pump.createPump
vertx.createHttpClient(host: 'humanstxt.org', port: 80)
.getNow('/humans.txt') { resp ->
println "GOT response with status $resp.statusCode"
resp.pause();
resp.endHandler {
println "response END with first registered handler"
}
@xhanin
xhanin / ovhcloud
Created February 26, 2012 16:02
slightly updated version of OVH public cloud script, allowing to ssh exec with "./ovhcloud instance ssh <instanceid> <command>" and remote copy with "./ovhcloud instance ssh <instanceid> copy <from> <to>"
#!/usr/bin/perl
use strict;
my $VERSION='v0.9';
#############
# PREPARING #
#############
my $URLS = {
session =>
@xhanin
xhanin / BatchUpdateVersions.groovy
Created December 21, 2011 17:33
A groovy script to batch update fixVersions in JIRA. Very slow but does the job. Use at your own risk!
/*
This groovy script is used to bulk update fixVersions in JIRA.
It uses a filter listing all issues in the project (to remove the version),
and a filter to which the fixVersion should be added.
INSTALLATION:
1) download and unzip atlassian cli:
https://studio.plugins.atlassian.com/wiki/display/ACLI/Atlassian+Command+Line+Interface
2) modify the jira.sh to include the server, your user name and password (as documented in the jira.sh)