Skip to content

Instantly share code, notes, and snippets.

View ogavrisevs's full-sized avatar

Oskars Gavriševs ogavrisevs

View GitHub Profile
@ogavrisevs
ogavrisevs / MySampleApplication.gwt.xml
Created December 29, 2011 12:41
GWT bug, ClickHandler not firing when CSS "position: absolute" added
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN"
"http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="MySampleApplication">
<inherits name='com.google.gwt.user.User'/>
<entry-point class='com.mySampleApplication.client.MySampleApplication'/>
</module>
@ogavrisevs
ogavrisevs / gist:2828423
Created May 29, 2012 13:38
Create pdf using iText from html
com.lowagie.text.Document document = new com.lowagie.text.Document();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PdfWriter.getInstance(document, outputStream);
HtmlWriter.getInstance(document, System.out);
document.open();
List<Element> objects = HTMLWorker.parseToList(reader, null, null);
for (Element element : objects) {
document.add(element);
}
@ogavrisevs
ogavrisevs / gist:2828437
Created May 29, 2012 13:41
Create pdf using iText 2.08 + ITextRenderer (R8 or R8pre) from html with styles
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(false);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
org.w3c.dom.Document doc = docBuilder.parse(stream);
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(doc, null);
renderer.layout();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@ogavrisevs
ogavrisevs / gist:2881356
Created June 6, 2012 11:25
Create pdf using iText 2.1.7 (manual add styles + unicode font )
InputStreamReader reader = new InputStreamReader(inputStream);
ByteArrayOutputStream outputStream = null;
try {
Document document = new Document();
outputStream = new ByteArrayOutputStream();
PdfWriter.getInstance(document, outputStream);
Map<String, String> pc2 = new HashMap<String, String>();
pc2.put("line-height", "115%");
@ogavrisevs
ogavrisevs / sample.java
Created June 7, 2012 07:06
Create pdf using pd4ml from html (html table is unsuported )
ByteArrayInputStream inputStream = new ByteArrayInputStream(htmlData);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PD4ML pd4ml = new PD4ML();
pd4ml.enableDebugInfo();
try {
pd4ml.setPageSize( PD4Constants.A4 );
pd4ml.setPageInsetsMM( new Insets(topValue, leftValue, bottomValue, rightValue) );
@ogavrisevs
ogavrisevs / hgAll.sh
Created October 17, 2012 14:20
Simple script for mercurial routine command autommation.
#!/bin/bash
#
# Simple script for mercurial routine command autommation.
# Execute mercurial commands for all repos found in current dir.
#
# Exmaple Usage
#
# $. <- current dir 1) hgAll.sh in - get all incoming commits
# $../repo1 2) hgAll.sh diff - uncommitted changes
# $../repo2 3) hgAll.sh st - uncommitted changes
@ogavrisevs
ogavrisevs / installHgKeyringExt.sh
Created October 26, 2012 09:35
Install mercurila keyring extension (for cygwin users)
#!/bin/bash
#
# Simple script to add keyring extension for mercurial.
# (only for cygwin users with native hg installation from debina package)
# This keyring extension enables password save so you do not need to enter it every time.
#
# Script install steps:
# 1) keyring lib from python rep.
# 2) downloads extension
# 3) configure mercurial to use keyring extension
@ogavrisevs
ogavrisevs / SyntaxHighlighterSample.html
Last active December 15, 2015 03:39
SyntaxHighlighter example
<!DOCTYPE html>
<html>
<head>
<title>SyntaxHighlighterSample</title>
</head>
<pre class="brush: java">public static void main(String args[]) {
System.out.println("Hello World!");
}
</pre>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
@ogavrisevs
ogavrisevs / build.gradle
Created October 7, 2013 20:01
joda time res. from nexus proxy
allprojects {
apply plugin: 'java'
dependencies{
compile "joda-time:joda-time:2.3"
}
repositories {
maven {
@ogavrisevs
ogavrisevs / gist:7373751
Created November 8, 2013 16:35
Java couses example
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def printCouse(cause) {
println("cause ========> : "+ cause )
println("cause.class ========> : "+ cause.class )