Thursday, February 28, 2013
OneWebSQL competition
Lately I'm spending most of the time on building my ego :))
First since very long time I've even won sth
http://onewebsql.com/konkurs-spring
http://e-point.pl/co-nowego?news_id=1500144,rozstrzygniecie-konkursu-na-najlepsza-aplikacje-webowa
My solution is available free on github. I must admit I would change a few things though, especially presentation layer - I would rewrite it in AngularJS.
Monday, February 25, 2013
MongoDB for Java Developers - 10gen Course
The course has just started today.
So far this week I gone through MongoDB installation, basic queries from mongo shell and Java application. I've also learned Spark Micro Web Framework and FreeMarket templating engine.
So far so good.. exercises were not to difficult and possible to go through in one night.
I've setup github project for this course at https://github.com/piczmar/MongoDB4JavaDev/
So far this week I gone through MongoDB installation, basic queries from mongo shell and Java application. I've also learned Spark Micro Web Framework and FreeMarket templating engine.
So far so good.. exercises were not to difficult and possible to go through in one night.
I've setup github project for this course at https://github.com/piczmar/MongoDB4JavaDev/
Sunday, January 6, 2013
Grails read-only domain class
Grails does not provide simple mapping to mark domain object read-only, means so that dynamic find methods (find, get, list..) work OK but save/delete is forbidden. This is particularly useful for legacy databases.
We can however provide desired behavior with low effort ourselved.
I could think out at least 2 ways of doing so:
1. listen on beforeXXX methods in domain class e.g.:
class Demo {
static constraints = {
}
String name
transient beforeUpdate = {
throw new RuntimeException('update not allowed')
}
}
2. send error status from controler REST method that is not allowed, e.g.:
def delete(Long id) {
response.sendError(405)
}
If you just want to disable an attribute of a domain class from being editable in scaffolded view you can use constraint:
class Demo {
static constraints = {
name(editable: false)
}
String name
}
Monday, December 24, 2012
Groovy Tips
Here are some productivity tips for Groovy development. Provided you have GROOVY_HOME/bin added to your path you can execute following commands:
groovyConsole
2. Add groovy.servlet.GroovyServlet to WEB-INF/web.xml.
3. Place your Groovy scripts wherever you'd normally place your JSP files.
4. Create hyperlinks to your Groovy scripts
- running Groovy shell
groovish
Type 'help' or '\h' for help.
-----------------------------------------------------------------------------------------------------------
groovy:000>
you can e.g. type:
Sting.methods.each{println it.name }
- running graphic console
groovyConsole
- running uncompiled Grovy on web server
1. Add groovy.jar from $GROOVY_HOME/embedded to server classpath (WEB-INF/lib)
2. Add groovy.servlet.GroovyServlet to WEB-INF/web.xml.
3. Place your Groovy scripts wherever you'd normally place your JSP files.
4. Create hyperlinks to your Groovy scripts
- automatic imports
Groovy automatically imports:import packages:
java.lang.*
java.util.*
java.net.*
java.io.*
java.math.BigInteger
java.math.BigDecimal
groovy.lang.*
groovy.util.*
- method pointers
In Groovy you can do the following:
def shoppingList = []
def add = shoppingList.&add
def remove = shoppingList.&remove
add "Milk"
add "Bread"
add "Beer"
remove "Beer"
add "Apple Juice"
print shoppingList
- operators
The following are operators and corresponding methods:
| Operator | Method |
| a == b or a != b | a.equals(b) |
| a+b | a.plus(b) |
| a-b | a.minus(b) |
| a*b | a.multiply(b) |
| a/b | a.div(b) |
| a%b | a.mod(b) |
| a++ or ++a | a.next() |
| a-- or --a | a.previous() |
| a&b | a.and(b) |
| a|b | a.or(b) |
| a[b] | a.getAt(b) |
| a[b] = c | a.putAt(b,c) |
| a << b | a.leftShift(b) |
| a >> b | a.rightShift(b) |
| a < b or a > b or a <= b or a >= b | a.compareTo(b) |
Thursday, November 1, 2012
All these new fancy web pages..
As a Java developer with long time experience I always found touching web pages a tiresome task. Messing up with all the HTML and JavaScript code, digging into CSS to make JSP render as expected was not an obvious thing. Still it is not. This is mainly because I never had enough time to understand CSS and JavaScript and I admit it was never priority number 1 knowing each web browser have its own specificity I just thought it' snot worth of trying. Better concentrate at Java word where most of the things is standardized and behaves as expected.
This was until I started to work closely with SmartClient and Grails.
Working closer with SmartClient library opened my eyes how much JavaScript evolved over the last years, how rapidly it develops and how amazing possibility it gives in comparison to what I met in legacy software in which it was just a little addition to all HTML rendered on server side. Now JavaScript is the place where all moves, flickers and rocks while server side is doing some business calculations not caring at all about front-end. It just takes data and returns data in desired format like JSON for instance.
Seeing a great potential in JavaScript I decided to learn more about it. By change there was a training organized in Poznan, Poland titled 'JavaScritp for Java Developers'. Wow, I thought this is exactly what I need, so I subscribed and I was not mistaken. The 2-days training gave me a feel of how to write modern JavaScript pages using technologies like BackboneJs, RequireJs, UnderscodeJs. I even learned there are unit tests written for it using libraries analogical to JUnit in Java word. It looks all this new JavaScript is not that far from ideas I know from Java world.
Still not sure if this is me who found JavaScript or JavaScipt found me, but today I came into another blog post that gave me a kick to learn more in this field.
Article written in Polish can be found at http://mamstartup.pl/felietony/2882/jak-buduje-sie-strony-internetowe-w-2012-roku and author's blog is here, also quite interesting.
The author is pointing out many interesting tools used in modern web development.
I hope to give them a try so I set up a project on github where I plan to gather some demo code of my trials with it. For now there are some web scaling example with CSS available.
I also found good designer's resources at http://www.smashingmagazine.com/
Some free e-books can be downloaded from here but I've downloaded the pdf and copied it to my github.
Saturday, September 1, 2012
My first meeting with Closure
I got inspired by video of life music hacking jam session http://www.youtube.com/watch?v=WXovdAEV_mI&hd=1
so that I wanted to try Overtone project myself.
First you need to install Lein which is a kind of depency managet for Clojure.
You can follow with instructions at https://github.com/technomancy/leiningen/#installation
What I did on Windows was downloading lein.bat from https://raw.github.com/technomancy/leiningen/preview/bin/lein.bat and stand-alone jar from https://github.com/technomancy/leiningen/downloads
Then I had to set env. variable LEIN_HOME to my local dir, e.g.: c:/tools/lein and put the stand-alone jar in
c:/tools/lein/self-installs
and add LEIN_HOME to PATH system variable so that lein.bat could be found globally in system.
Then when I typed
Now I can start playing with Overtone...
Then you download sources from github:
and build project with
Now launch REPL and follow according to steps at Overtone github:
so that I wanted to try Overtone project myself.
First you need to install Lein which is a kind of depency managet for Clojure.
You can follow with instructions at https://github.com/technomancy/leiningen/#installation
What I did on Windows was downloading lein.bat from https://raw.github.com/technomancy/leiningen/preview/bin/lein.bat and stand-alone jar from https://github.com/technomancy/leiningen/downloads
Then I had to set env. variable LEIN_HOME to my local dir, e.g.: c:/tools/lein and put the stand-alone jar in
c:/tools/lein/self-installs
and add LEIN_HOME to PATH system variable so that lein.bat could be found globally in system.
Then when I typed
leinin system console it downloaded missing Clojure dependencies and welcomed me with message:
Leiningen is a tool for working with Clojure projects.
Several tasks are available:
check Check syntax and warn on reflection.
classpath Write the classpath of the current project to output-file.
clean Remove all files from project's target-path.
compile Compile Clojure source into .class files.
deploy Build jar and deploy to remote repository.
deps Show details about dependencies.
do Higher-order task to perform other tasks in succession.
help Display a list of tasks or help for a given task.
install Install current project to the local repository.
jar Package up all the project's files into a jar file.
javac Compile Java source files.
new Generate project scaffolding based on a template.
plugin DEPRECATED. Please use the :user profile instead.
pom Write a pom.xml file to disk for Maven interoperability.
repl Start a repl session either with the current project or standalone.
retest Run only the test namespaces which failed last time around.
run Run the project's -main function.
search Search remote maven repositories for matching jars.
show-profiles List all available profiles or display one if given an argument.
test Run the project's tests.
trampoline Run a task without nesting the project's JVM inside Leiningen's.
uberjar Package up the project files and all dependencies into a jar file.
upgrade Upgrade Leiningen to specified version or latest stable.
version Print version for Leiningen and the current JVM.
with-profile Apply the given task with the profile(s) specified.
Run lein help $TASK for details.
See also: readme, faq, tutorial, news, sample, profiles,
deploying and copying.
Now I can start playing with Overtone...
Then you download sources from github:
git clone git://github.com/overtone/overtone.git
and build project with
lein deps
Now launch REPL and follow according to steps at Overtone github:
The quickest way to get started is to launch a clojure repl using lein. In the overtone project directory....
$ lein repl
Then make some noise :)
user> (use 'overtone.live)
...wait a bit...
user> (demo (sin-osc))
For a better experience try Overtone in emacs or Overtone in vim.
Unfortunately that ain't that easy and first command: (use 'overtone.live) brought me to error message:
--> Loading Overtone...
UnsatisfiedLinkError Unable to load library 'scsynth': Nie mo┐na odnalečŠ okreťlonego modu│u.
com.sun.jna.NativeLibrary.loadLibrary (NativeLibrary.java:169)
I wish you were more lucky, I will come back to resolve it in a while..stay tuned...
Soo.. after a while I'm back with a different approach.
I followed the following steps:
From command line execute:
edit project.clj generated in folder tutorial and add dependency:
Then type:
Start REPL (https://github.com/overtone/overtone/wiki/Starting-a-REPL)
and start playing... (https://github.com/overtone/overtone/wiki/Getting-Started)
Soo.. after a while I'm back with a different approach.
I followed the following steps:
From command line execute:
lein new tutorial
cd tutorial
edit project.clj generated in folder tutorial and add dependency:
(defproject tutorial "1.0" :dependencies [ [org.clojure/clojure "1.3.0"] [overtone "0.7.1"] ])
Then type:
lein depsInstall SuperCollider (http://sourceforge.net/projects/supercollider/files/Windows/) - during installation enter installation folder name as SuperCollider, without version number. I'm not sure if otherwise Overtune will locate scsynth.exe correctly.
Start REPL (https://github.com/overtone/overtone/wiki/Starting-a-REPL)
lein replType commands:
(use 'overtone.core)
(boot-external-server)
and start playing... (https://github.com/overtone/overtone/wiki/Getting-Started)
Saturday, May 5, 2012
JSON editor for Eclipse
Simple and handful editor from
http://sourceforge.net/projects/eclipsejsonedit/ , however installation was not that obvious. 'Install from zip file' did not work for me. It was sufficient to unzip content and copy 'plugins' and 'features' content to 'plugins' and 'features' folders in eclipse installation. Works for me :) Checked on Eclipse Inigo and Spring Source Tools Suite.
Subscribe to:
Posts (Atom)