avatar

Andres Jaimes

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: SET DEFINE OFF; 3. Adjust page width and size set pagesize 1000 set linesize 100 4.

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 content like this: myapp >> output.log As well as with output, it is very useful to redirect the stderr (standard error output) to a file rather than to the screen.

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 SQLException { Connection conn = null; Properties p = new Properties(); p.put("user", "username"); p.put("password", "superpassword"); String cs = "jdbc:mysql://localhost/demo"; conn = DriverManager.

Installing Lucene/Solr on CentOS 6

This time we are going to install Solr, the super text search platform on CentOS. The installation process requires a couple extra libraries in order to work: Apache Commons Logging and SLF4J. Installing Java yum install java java -version You must have at least version 1.6 in order to run Solr. If you got Java 1.5, I recommend you to follow this tutorial to get version 1.6. Installing Tomcat yum -y install tomcat6 tomcat6-webapps tomcat6-admin-webapps chkconfig tomcat6 on service tomcat6 start Use a web browser to check it is working correctly.

Installing Java 1.6 on CentOS 6

Java 1.5 is the default Java version you get when you ask yum to install it on CentOS. However, several applications need 1.6 in order to run. Just follow the next steps to install it. Remove Java 1.5 yum remove java-1.5-* Install the rpmforge repository cd rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt Check if you have a 32 or 64 CentOS version uname -a For 32 versions (i686) download and install the following repository

WordPress Snippets

As a WordPress developer I have collected / created / curated many snippets that I’ve used in my projects. I hope you find them useful.  General HTML / WordPress tags Get your template’s directory <link href="<?php echo get_template_directory_uri(); ?>/style.css" rel="stylesheet" media="screen"> Check if this is the home page <?php if (is_home()) { ... } ?>  Remove the wp_generator tag in the Head section of your HTML I recommend you to add this line for security reasons.

iptables snippets

iptables is the default firewall you see on any linux computer. It works by allowing (ACCEPTing) or denying (DROPing) connections to the local computer. There are basically three scenarios you can deal with: INPUT: Connections generated from a different computer targeting yours; for example, when you run a web server on your computer and others want to connect to it. OUTPUT: Connections generated from your computer targeting other computers; for example, when you open a web page or open a remote ssh session.

Calvin & Hobbes on real scenery

A set of beautiful images found on the Internet by an unknown artist.

How to connect to MySQL from a remote server

In few words, you have to configure MySQL to allow remote connections, create a user for connecting and setup your firewall to allow it. You don’t have to do this if you are only connecting from a local application like WordPress. You need root permissions to perform the following commands.  Configuring MySQL Edit the MySQL configuration file. nano /etc/my.cnf Allow connections from all your network interfaces by commenting out the following line: