Some libraries have duplicate dependencies.
If you want prevent errors and warnings you should exclude duplicates from one of library:
compile (‘org.docx4j:docx4j-ImportXHTML:3.2.1’) { exclude “slf4j-log4j12” }
Some libraries have duplicate dependencies.
If you want prevent errors and warnings you should exclude duplicates from one of library:
compile (‘org.docx4j:docx4j-ImportXHTML:3.2.1’) { exclude “slf4j-log4j12” }
Create Gradle Spring Boot project with SPRING INITIALIZR
I chose Groovy language for the project, but if you want Java, text below with little changes also helps you.
Edit build.gradle and add to it bootRun section
buildscript { ext { springBootVersion = '1.3.1.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'groovy' apply plugin: 'idea' apply plugin: 'spring-boot' jar { baseName = 'myapp' version = '0.0.1-SNAPSHOT' } sourceCompatibility = 1.8 targetCompatibility = 1.8 repositories { mavenCentral() } dependencies { compile('org.codehaus.groovy:groovy') testCompile('org.springframework.boot:spring-boot-starter-test') } task wrapper(type: Wrapper) { gradleVersion = '2.9' } // this code split parameters and allow us use parameters in our application bootRun { if ( project.hasProperty('args') ) { args project.args.split('\\s+') } }
create MyController class
@Controller class MyController implements CommandLineRunner { private Logger logger = LoggerFactory.getLogger(this.getClass()) @Override void run(String... args) throws Exception { if(!args) { logger.warn("You must pass at least one parametr.") logger.warn("Example: bootRun -Pargs=\"arg1 arg2 arg3\"") } // print parameters which we sent from command line args.each{ arg -> logger.info(arg) } } }
Run application
gradle bootRun -Pargs=”arg1 arg2 arg3″
First off all you could find out some plugins https://grails.org/plugins/search?q=mongo
1. Edit BuildConfig.groovy
add string like this: compile ‘org.mongodb:mongo-java-driver:3.0.3’ to dependencies section
dependencies { //... compile 'org.mongodb:mongo-java-driver:3.0.3' }
2. Edit Config.groovy
mongodb.uri = "mongodb://username:password@your.mongodb.server/yourDataBaseName" mongodb.database = "yourDataBaseName"
3. Add to resources.groovy
beans = { mongoClientURI(MongoClientURI) { bean -> bean.constructorArgs = [grailsApplication.config.mongodb.uri.toString()] } mongoClient(MongoClient) { bean -> bean.constructorArgs = [ref(mongoClientURI)] bean.destroyMethod = 'close' } mongoDb(mongoClient: 'getDB') { bean -> bean.constructorArgs = [grailsApplication.config.mongodb.database.toString()] } }
4. Add to any controller (in my case MyController)
package mypackage import com.mongodb.DB class MyController { DB mongoDb def users() { def collection = mongoDb.getCollection('myCollection') collection.insert(new BasicDBObject(['name':'Piter'])) def users = collection.find(new BasicDBObject(['name':'Piter'])).toArray() render (contentType: 'application/json', text: JSON.serialize(users)) } def user() { def userId = params.userId def collection = mongoDb.getCollection('myCollection') def user = collection.findOne(new BasicDBObject(['_id': new ObjectId(userId)])) render (contentType: 'application/json', text: JSON.serialize(user)) } }
For correct sorting of strings in Ukrainian or any other language, you must explicitly specify the locale Locale. To solve this problem, we use the class from the package java.text – Collator.
ArrayList<String> countries = new ArrayList<String>(); countries.add("Єгипет"); countries.add("Туреччина"); countries.add("Ісландія"); countries.add("Аргентина"); System.out.println("Before sort:"); System.out.println(countries); System.out.println("After regular sort:"); Collections.sort(countries); System.out.println(countries); Locale ukrainian = new Locale("uk", "UA"); Collator ukrainianCollator = Collator.getInstance(ukrainian); Collections.sort(countries, ukrainianCollator); System.out.println("After locale sort:"); System.out.println(countries);Results
Before sort:
[Єгипет, Туреччина, Ісландія, Аргентина]
After regular sort:
[Єгипет, Ісландія, Аргентина, Туреччина]
After locale sort:
[Аргентина, Єгипет, Ісландія, Туреччина]
I have some view (“basicView.gsp”) and want to pass other view content (“_someTemplate.gsp”) to this view to javascript variable (“template”).
basicView.gsp:
<html> <head> ... </head> <body> ... <script> var template = '${raw(include(view:"myTemplates/_someTemplate.gsp").replaceAll('\n',''))}'; </script> </body> </html>
_someTemplate.gsp:
<div> <h1>Some header</h1> <p>Lorem ipsum dolor sit...</p> </div>
Resulted html:
<html> <head> ... </head> <body> ... <script> var template = '<div><h1>Some header</h1><p>Lorem ipsum dolor sit...</p></div>'; </script> </body> </html>
Details:
Create Grails app in ItelliJ IDEA 14 as in this manual –
https://vaadin.com/wiki/-/wiki/Main/Vaadin+on+Grails+-+Create+project+in+IntelliJ+IDEA
But use only 1. and 2. points.
After 2. point use next suggestions:
add to BuildConfig.groovy:
to dependencies – runtime ‘org.hibernate:hibernate-validator:5.1.1.Final’
to plugings – compile “:vaadin:7.5.2”
click Apply Grails changes to IDEA project structure
run – grails vaadin-quickstart
Next couple steps:
press “+” and select Grails:
select “your app” in Module:
change name on “your app name”:
result:
Thats all.
def someMap = [ 'phones':['iPhone','Galaxy','Nexus'], 'laptops':['HP','MacBook','Samsung'], 'tablets':['Galaxy Tab','iPad','Asus'], ] someMap.eachWithIndex{ k, v, index -> println "${k}:${v} - ${index}" }
Result:
phones:[iPhone, Galaxy, Nexus] – 0
laptops:[HP, MacBook, Samsung] – 1
tablets:[Galaxy Tab, iPad, Asus] – 2
def map = [a:"cc", b: "dd"] println "map - " + map println "map.keySet() - " + map.keySet() println "map.values() - " + map.values() println "map.entrySet() - " + map.entrySet() println "map.entrySet().key - " + map.entrySet().key println "map.entrySet().value - " + map.entrySet().value
Result:
map – [a:cc, b:dd]
map.keySet() – [a, b]
map.values() – [cc, dd]
map.entrySet() – [a=cc, b=dd]
map.entrySet().key – [a, b]
map.entrySet().value – [cc, dd]
apt-get install pptpd
nano /etc/pptpd.conf
localip 10.0.0.1
remoteip 10.0.0.100-200
nano /etc/ppp/chap-secrets
username pptpd password *
nano /etc/ppp/pptpd-options
ms-dns 8.8.8.8
ms-dns 8.8.4.4
service pptpd restart
check:
netstat -alpn | grep :1723
nano /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE && iptables-save
iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables -I INPUT -s 10.0.0.0/8 -i ppp0 -j ACCEPT
iptables --append FORWARD --in-interface eth0 -j ACCEPT
# ======================== ufw ===================
ufw allow 22
ufw allow 1723
nano /etc/ufw/before.rules
# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow forward traffic to eth0
-A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
# Process the NAT table rules
COMMIT
# before the line # drop INVALID packets ... add:
-A ufw-before-input -p 47 -j ACCEPT
ufw disable
ufw enable
Nothing boded trouble, OS X notified me about system updates. Apple has recommended updating the SMC to address potential battery issues in the future, here is a link to this update http://support.apple.com/kb/DL1626. Installing the update failed, the system rebooted, and as a result, my Mac started making noise like a helicopter cooler, after which it was necessary to install the same update again. After rebooting, I saw the icon:
later I found out that this means this system cannot be loaded on your device.
After this incident, an unimaginable number of experiments were carried out, as well as visits to several authorized Apple centers in Kyiv, a series of calls to the Apple representative office in Moscow (since there is no such representative office in Ukraine, there is only an official distributor). The result turned out to be disappointing: the service center offered to replace the motherboard under the exchange program, the amount was about $500. Naturally, I did not spend such money to restore the device of 2010 release …
The most interesting thing that I managed to put on Mac Os X 10.6.8 and it even loaded, and I could see the desktop and controls, but it lasted no more than 2-3 seconds, after which the device went to sleep, after pressing any buttons, the system was activated again, but the screen backlight did not turn on, consider that either it was possible only in bright light, after 2-3 seconds the Mac fell asleep again … Having taken a screenshot from “About this Mac”-> “System Report” I I saw that the above update somehow miraculously flashed my SMC device for MacBook Pro (13-inch, Early 2011) this can be seen in the screenshot, judging by Apple http://support.apple.com/kb/HT1237:
The MacBook was “solemnly” put on the shelf until better times or for sale for parts.
A few months later, it was decided to sell the semi-working device. I took a picture of the device and finally with a friend decided to torment him again. A friend found an adapter to DVI and we connected the Mac to an external monitor, to our surprise it worked, but the native screen was not active, and the cooler also worked without turning off. Since we got the opportunity to manipulate the device indefinitely, we armed ourselves with Google and carried out a series of successful actions, as it turned out later.
So the recipe: