Examples of ‘for’ queries with Scala

On this page you are going to find some examples of ‘for’ queries. Let’s start by defining the following database: case class Book(title: String, authors: List[String]) val books: List[Book] = List( Book(“structure and interpretation of computer programs”, List(“abelson, harald”, “sussman, gerald j.”)), Book(“introduction to functional programming”, List(“bird, richard”, “wadler, phil”)), Book(“effective java”, List(“bloch, joshua”)), Book(“java…

Enterprise Architect – Synchronize model from a live database

Synchronize a model from a live database to Enterprise Architect. Select your database from the Database Model folder in Project Browser. Go to Tools > Database Builder Right click on Tables > Show Differences. We can also click on a different type of object. a. An active connection is needed to complete the previous step….

Running Pentaho Data Integration on Mac OSX

Run Pentaho Data Integration on Mac OSX. The following procedure works with all the latest OSX versions. My local configuration OSX Mojave OpenJDK 11 Procedure Download pdi-ce-8.1.0.0-365.zip from https://sourceforge.net/projects/pentaho/ Unzip it Using the terminal, cd into the unzipped directory Run the application open Data\ Integration.app If you get the following error: LSOpenURLsWithRole() failed with error…

PlayFramework – Java

So far I have really liked this concept. The only con is that some times is difficult to find full examples that use the latest version. Installing sbt We need sbt for compiling and running Play applications. brew install sbt@1 Executing a first application Check the tutorials page to see how to create a first…

Password Requirements Validation with JQuery

Password screens are challenging for users because we often ask them to enter complex strings which most times are not even able to see. Adding to it, these strings have to meet different criteria – like having upper and lower case characters, numbers and so on – to keep our applications secure. In this post,…

How to run a custom update using Java JPA

From time to time it is necessary to execute a query without using Java’s JPA infrastructure. In order to do it, we have to define a NamedQuery to execute. In this example, I will run an update against the database. @Entity @NamedQueries ({ @NamedQuery ( name = "SomeEntity.TestQuery", query = "update SomeEntity se set se.myField…

Quick lessons on working with Java’s BigDecimal

Today I bring an example of the different results you can expect when using Java’s BigDecimal class. From instantiation to applying different arithmetic operations, it is important to understand how they affect the resulting instances. The following program shows different scenarios and results applied to BigDecimal’s. package test; import java.math.BigDecimal; import java.math.RoundingMode; public class Test…

How to read a file name argument from the command line in C++

Reading a file name parameter from the command line is a common task. In this post I read a file name and validate it exists. For paths and file names that include spaces, you have to pass them between quotes, otherwise they will be interpreted by the operating system as two different parameters. #include <string>…

How to check command line arguments in any order

Here is an easy solution to passing parameters to a C++ application from the command line that does not require any external libraries. Since parameters are read inside a loop, the order in which they are passed is not important. #include <string> #include <iostream> int main(int argc, char* argv[]) { for (int i = 1;…

Solution: Netbeans 8 not working on Ubuntu 15.10

Netbeans is one of my beloved day to day applications. Yesterday, when I installed Ubuntu 15.10 (Wily Werewolf) on my computer, Netbeans started to hang on the startup screen, specifically at the Loading Modules phase. It took me hours looking for solutions on the internet; and reinstalling different versions of the Java Development Framework didn’t…

Support Glumik!

Hello, This time I write to ask you for your support. We’re developing a website for small business owners in the City of Queretaro, Mexico. The website will allow the proprietors have presence on the Internet. Many of these people do not have the resources for starting a website and we want to help them….

Installing CentOS 7 – A Graphical Tour for Linux Beginners

If you are new on the Linux platform, I am sure you feel overwhelmed with all the different versions available. Choosing one is not an easy task, and each version has its own pros and cons. Let me tell you why I like CentOS: It is very stable It has well tested features There is a…

Compiling and Debugging Oracle's Pro*C files in OS-X / Xcode

Part of my work as a Web/UNIX developer includes maintenance and development of tools using Oracle’s Pro*C. In text interfaces, VIM is a pretty decent tool for creating source code and their companion make files. If you created the right make file, compiling is also a breeze. However things get kind of tricky when you…

The Rationale behind the Creation of a Model-View-Controller Framework: Fantastic

Important: This is a work in progress document. The Model-View-Controller is a software pattern frequently used for web development. As its name states, it is composed by three components: A Model or domain representation of a problem. It receives commands, processes them and modifies its state according to the input provided. A View whose main…

Oracle Snippets

This post will be updated with snippets for Oracle. I hope you find it useful.   1. Change the default date format Most useful snippet of the year! 😉 ALTER SESSION SET NLS_DATE_FORMAT = ‘MM/DD/YYYY HH24:MI:SS’; select sysdate from dual; 2. Escape single quotes and ampersands on strings Single quotes: select ‘D”Angelo”s’ from dual; Ampersands:…

How to redirect stdout / stderr to a file

Redirecting all your program output to a file is very simple and can be accomplished like this: myapp > output.log This line will send all the output generated by myapp to a file named output.log. The contents of output.log will always be overwritten; but you can use a second > to append to the current…

Intro to Responsive Web Design

This weekend I was invited to have a remote presentation on Responsive Web Design with students from the Autonomous University of Queretaro (UAQ) in Mexico. Introductory concepts are presented in code, so you have the chance to apply them immediately. The video is in spanish. Happy coding.

Create a connection to MySQL in Java

This time we are going to create a basic connection to MySQL in Java and pull some data from it. // Compile it: // javac Mysql.java // // Try it: // java -classpath mysql-connector-java-5.1.27-bin.jar:. MySQL import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; public class MySQL { public Connection getConnection() throws…