Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / 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 / 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 / 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 / plugin.groovy
Created February 13, 2013 22:20
ISO DateTime / Epoch timestamp converter plugin for IntellijEval
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.editor.SelectionModel
import org.joda.time.*
import static intellijeval.PluginUtil.*
// add-to-classpath $HOME/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar
registerAction("TransformDateISOEpoch", "ctrl alt shift T") { AnActionEvent event ->
def editor = currentEditorIn(event.project)
@xhanin
xhanin / plugin.groovy
Created February 18, 2013 17:16
Remove all setters or getters in a class (IntellijEval plugin). Example use case: move from regular getters/setters to fluent interface: - use this plugin to remove getters / setters - use http://code.google.com/p/idea-generate-fluent-interface/ to generate fluent interface methods
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiModifier
import com.intellij.psi.util.PsiTreeUtil
import static intellijeval.PluginUtil.*
def findContextClass = { project ->
def editor = currentEditorIn(event.project);
@xhanin
xhanin / install-mongodb-deb.sh
Created September 11, 2013 21:52
A script to install MongoDB on Debian, based on instructions provided here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install -y mongodb-10gen
@xhanin
xhanin / gist:6965995
Created October 13, 2013 18:57
diff 2 directories in zsh
# suppose you have a set of files in target/base-deps
# and want to remove files in target/dependency with the same names
for f (target/base-deps/*.jar) {rm $f:s/base-deps/dependency/}
<repositories>
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
</repositories>