lunes, 31 de julio de 2017

EXT4 virtual disk optimization

Hi all,

These are my tweaks in order to squeeze the performance of a EXT4 virtual disk (in example /dev/sdb1).

ALERT
No implicit nor explicit warranty of any kind is stated here. These commands and/or settings may cause data loss. Use them wisely at your own risk!

tune2fs -o journal_data_writeback /dev/sdb1
tune2fs -O ^has_journal /dev/sdb1
sudo e2fsck -f /dev/sdb1
#
tune2fs -o ^user_xattr /dev/sdb1
tune2fs -o ^acl /dev/sdb1
tune2fs -o nobarrier /dev/sdb1
tune2fs -o discard /dev/sdb1
#
tune2fs -O ^dir_index /dev/sdb1
tune2fs -O ^dir_nlink /dev/sdb1
tune2fs -O ^huge_file /dev/sdb1
tune2fs -O ^metadata_csum /dev/sdb1
tune2fs -O ^quota /dev/sdb1
tune2fs -r 0 /dev/sdb1
#

dumpe2fs /dev/sdb1 | less


References and Kudos:

  1. https://developer.ridgerun.com/wiki/index.php/High_performance_SD_card_tuning_using_the_EXT4_file_system

sábado, 1 de abril de 2017

JSF 2.1 within embedded Tomcat 8 (2017)

This post relates about configuring the following aspects to get a working JSF 2.1 application:
  • Maven 3
  • JSF 2.1.7
  • Embedded Tomcat 8

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>eu.altotek</groupId>
 <artifactId>spa-jsf-generator</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>
 <name>spa-jsf-generator Maven Webapp</name>
 <url>http://maven.apache.org</url>

 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
  <java.version>1.8</java.version>

  <jsf.version>2.1.7</jsf.version>
  <jsp-api.version>2.2.1-b03</jsp-api.version>

  <tomcat.version>8.0.28</tomcat.version>
 </properties>

 <dependencies>
  <!-- JSF -->
  <dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-api</artifactId>
   <version>${jsf.version}</version>
   <scope>runtime</scope>
  </dependency>
  <dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-impl</artifactId>
   <version>${jsf.version}</version>
   <scope>runtime</scope>
  </dependency>

  <!-- Java standards -->
  <dependency>
   <groupId>org.glassfish.web</groupId>
   <artifactId>el-impl</artifactId>
   <version>2.2</version>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
  </dependency>
  <dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>jsp-api</artifactId>
   <version>${jsp-api.version}</version>
  </dependency>

  <!-- Tomcat -->
  <dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-core</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-logging-juli</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-jasper</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>tomcat-jasper</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>tomcat-jasper-el</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>tomcat-jsp-api</artifactId>
   <version>${tomcat.version}</version>
  </dependency>

  <!-- Testing -->
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.12</version>
   <scope>test</scope>
  </dependency>
 </dependencies>
 <build>
  <finalName>spa-jsf-generator</finalName>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
     <source>${java.version}</source>
     <target>${java.version}</target>
    </configuration>
   </plugin>
  </plugins>
 </build>
</project>

web.xml

<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 id="WebApp_ID" version="2.5">

 <context-param>
  <param-name>javax.faces.PROJECT_STAGE</param-name>
  <param-value>Development</param-value>
 </context-param>

 <welcome-file-list>
  <welcome-file>/jsf/home.jsf</welcome-file>
 </welcome-file-list>

 <listener>
  <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
 </listener>

 <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.jsf</url-pattern>
 </servlet-mapping>

</web-app>

Main.java

package eu.altotek.spa_jsf_generator;

import java.io.File;

import org.apache.catalina.WebResourceRoot;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.DirResourceSet;
import org.apache.catalina.webresources.StandardRoot;

public class Main {

 public static void main(final String[] args) throws Exception {

  final String webappPath = new File("src/main/webapp").getAbsolutePath();
  final Tomcat tomcat = new Tomcat();

  final StandardContext ctx = (StandardContext) tomcat.addWebapp("/", webappPath);

  // Declare an alternative location for your "WEB-INF/classes" dir
  // Servlet 3.0 annotation will work
  final String targetClassesPath = new File("target/classes").getAbsolutePath();
  final WebResourceRoot resources = new StandardRoot(ctx);
  resources.addPreResources(new DirResourceSet(//
    resources, "/WEB-INF/classes", //
    targetClassesPath, "/"));
  ctx.setResources(resources);

  tomcat.start();
  tomcat.getServer().await();
 }
}

webapp/jsf/home.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JSF Tutorial!</title>
</head>

<body>
#{helloWorld.message}
</body>
</html>

HelloWorld.java

package eu.altotek.spa_jsf_generator.jsf;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class HelloWorld {

 public HelloWorld() {
  System.out.println(this + "started!");
 }

 public String getMessage() {
  return "Hello " + this;
 }
}

References & kudos

  • https://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/
  • http://musingsofaprogrammingaddict.blogspot.com.es/2009/12/running-jsf-2-on-embedded-jetty.html
  • https://www.mkyong.com/jsf2/jsf-2-0-tomcat-it-appears-the-jsp-version-of-the-container-is-older-than-2-1/
  • https://www.tutorialspoint.com/jsf/jsf_first_application.htm
  • http://alexgorbatchev.com/SyntaxHighlighter/

viernes, 15 de enero de 2016

Instalación paso a paso de Linux Mint 17 via PXE/Netboot

Hola,

Después de un breve descanso, he querido instalar un linux en un portátil un poco antiguo, y la distrubución escogida ha sido Linux Mint 17.3 (Rosa).

Aquí están las instrucciones para hacer una instalación desde red (mediante PXE+dnsmasq+TFTP+NFS) :

NOTA: Hay que cambiar la IP 192.168.0.159 por la tuya!!

sudo bash
apt-get install dnsmasq nfs-kernel-server nfs-common syslinux

# archivos
mkdir -p /srv/tftp/pxelinux.cfg
ln -s /cdrom /tmp/cdrom

# dhcp/tftp
cat <<EOF > /srv/tftp/pxelinux.cfg/default
DEFAULT /cdrom/casper/vmlinuz
KERNEL cdrom/casper/vmlinuz
APPEND ip=dhcp netboot=nfs boot=casper root=/dev/nfs nfsroot=192.168.0.159:/tmp/cdrom/ initrd=/cdrom/casper/initrd.lz splash --
EOF

cat <<EOF >> /etc/dnsmasq.conf

interface=eth0
dhcp-range=192.168.0.240,192.168.0.250,1h
dhcp-boot=pxelinux.0,mint,192.168.0.159
enable-tftp
tftp-root=/srv/tftp
EOF
service dnsmasq restart

# nfs
cat <<EOF >> /etc/exports

/tmp/cdrom       *(ro,sync,fsid=0,no_subtree_check)
EOF
service nfs-kernel-server restart ; exportfs -a

A disfrutar!

jueves, 28 de febrero de 2013

iPhone Jailbreak + Cydia with Evasi0n: The easy/direct way

After Apple lost most of it's credit and "coolness" caused mainly by the rain of patches for it's iOS 6, I decided to stop (at 6.0.1) and jailbreak-free from this madness.

I consider myself a newcomer to the iPhone world, so I expected waste time (and gallons of sweat) to jailbreak an iPhone 4 but after I tried (and claimed the refund from) iphonejailbreakunlock.org I was lucky to find a post at iphoneros.com (spanish) site[2], telling that the Evad3rs Team were able to jailbreak iOS up to 6.1.2!

No redsnow, no .IPSW files, I just downloaded the (tiny) package from the main site[3], ran it and voila! Everything worked like a charm. :)

More information:
  1. http://www.macworld.com/article/2010812/bugs-and-fixes-troubleshooting-ios-6.html
  2. http://iphoneros.com/30416/evasi0n-1-4-para-ios-6-1-2-ya-disponible
  3. http://evasi0n.com/

sábado, 26 de enero de 2013

Bienvenida

Gracias por venir!

Aquí encontrarás información y opiniones principalmente de programación y tecnología, experiencias y algún que otro truco.

Espero que disfrutemos y aprendamos todos de esta aventura!

Alejandro.