Skip to content

Instantly share code, notes, and snippets.

View gAmUssA's full-sized avatar
so hard

Viktor Gamov gAmUssA

so hard
View GitHub Profile
@gAmUssA
gAmUssA / gist:3785610
Created September 26, 2012 02:15
Read from file, Java 6 example
try{
FileReader fileReader = new FileReader("blah.txt");
BufferedReader reader = new BufferedReader(fileReader);
try{
String line = nul;;
while((line = reader.readLine())!=null){
System.out.println(line);
}
finally{
reader.close();
@gAmUssA
gAmUssA / gist:3785615
Created September 26, 2012 02:17
Read file, Groovy example
new File("blah.txt").eachLine{line-> printline(line)}
@gAmUssA
gAmUssA / script.sh
Created October 19, 2012 04:00
Markdown and Asciidoc commands
# markdown to asciidoc
pandoc -f markdown -t asciidoc -S
# html generation from asciidoc
asciidoc -b html5 -a icons -a iconsdir=`brew --prefix asciidoc`/etc/asciidoc/images/icons -a theme=flask -a data-uri -a toc2 book.asciidoc
# pdf generation from asciidoc
# prerequisite: brew install fop
# TODO: images doesn't embed
a2x -fpdf -dbook --fop --icons --icons-dir=iconsdir=`brew --prefix asciidoc`/etc/asciidoc/images/icons book.asciidoc
@gAmUssA
gAmUssA / exceptions.md
Created October 19, 2012 17:52
small note about unchecked and checked exceptions in Java

Unchecked exceptions :

  • represent defects in the program (bugs) - often invalid arguments passed to a non-private method. To quote from The Java Programming Language, by Gosling, Arnold, and Holmes :

«Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time.»

  • are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException
  • a method is not obliged to establish a policy for the unchecked exceptions thrown by its implementation (and they almost always do not do so)

Checked exceptions :

@gAmUssA
gAmUssA / build_cdb.md
Created October 21, 2012 04:25
WORK-IN-PROGRESS: Building Clear DataBuilder instructions

Building Clear DataBuilder

Checking out projects

  • cdb.dto2extjs.annotations
  • cdb.dto2extjs.plugin
  • ClearJS
  • clear-extjs-runtime-core
  • clear-extjs-runtime-djn
@gAmUssA
gAmUssA / init_db.sql
Created October 25, 2012 19:56
ClearDataBuilder sample database for Oracle
-- http://jen.fluxcapacitor.net/geek/autoincr.html
drop sequence company_id_seq;
create sequence company_id_seq
start with 10
increment by 1
nomaxvalue;
-- select company_id_seq.nextval from dual;
@gAmUssA
gAmUssA / AssociateMapper.java
Created October 25, 2012 20:05
CompanyMapper and AssociateMapper for Oracle ClearDataBuilder sample
package com.farata.example.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
@gAmUssA
gAmUssA / context.xml
Created October 25, 2012 20:17
Tomcat's context.xml with Oracle DataSource
<?xml version="1.0" encoding="UTF-8"?>
<Context privileged="true" antiResourceLocking="false"
antiJARLocking="false" reloadable="true">
<!-- JOTM -->
<Transaction factory="org.objectweb.jotm.UserTransactionFactory"
jotm.timeout="60" />
<Resource name="jdbc/cleardb" auth="Container" type="javax.sql.DataSource"
username="admin" password="secret" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1522:xe"
@gAmUssA
gAmUssA / build.gradle
Created October 25, 2012 20:24
generic gradle build from ClearDataBuilder example project
apply plugin: 'war'
apply plugin: 'eclipse'
sourceCompatibility = 1.6
targetCompatibility = 1.6
def mybatisVersion = '3.0.4'
def gsonVersion = '2.2.1'
def springVersion = '3.1.0.RC1'