Skip to content

Instantly share code, notes, and snippets.

@zonia3000
zonia3000 / android-static-tethering-howto.md
Last active January 5, 2024 16:22
Android USB tethering with static IP address (fix broken tethering)

Android USB tethering with static IP address (fix broken tethering)

On the custom ROM I'm using (James Rom D500) there is something broken with DHCP setup, so, even if the USB tethering is active from phone settings, the computer will never receive a valid IP address.

These steps worked for me for setting up a static IP address:

Laptop configuration (from GUI)

  • Address: 192.168.42.121
@zonia3000
zonia3000 / dockerbash.md
Last active August 25, 2019 09:11
Bash function for opening a bash inside a Docker container specifying the image name instead of the id

dockerbash

Why?

When working on a Dockerfile I often need to open a bash inside the generated container in order to check what the Dockerfile has generated.

This requires 3 steps:

  • running docker ps
  • checking the container id that we need (usually based on the image name)
@zonia3000
zonia3000 / tomcat_weld_howto.md
Last active April 9, 2018 07:46
Enable WELD+JAX-RS+JSF on Tomcat (Maven project)

In src/main/webapp/WEB-INF/web.xml add:

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

    <!-- ... -->

    <resource-env-ref>
        <resource-env-ref-name>BeanManager</resource-env-ref-name>
@zonia3000
zonia3000 / httpd-mod-php56.md
Created June 29, 2017 07:53
CentOS 7: install new Apache/httpd PHP module without removing older PHP installation.

I wanted to switch from PHP 5.4 to PHP 5.6 without remove the older version from the machine.

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi-php56
yum update
yum install php56 php56-php

In /etc/httpd/conf.modules.d you now should have 2 different files for configuring PHP: 10-php56-php.conf 10-php.conf Rename the oldest and restart the server.

@zonia3000
zonia3000 / glassfish.sh
Last active December 2, 2016 11:12
GlassFish 4 System V init script
#!/bin/bash
#
# glassfish: Startup script for Glassfish Application Server.
#
# chkconfig: 3 80 05
# description: Startup script for domain1 of Glassfish Application Server.
ASADMIN="/home/glassfish/glassfish4/glassfish/bin/asadmin"
USER="glassfish"
@zonia3000
zonia3000 / basic-auth-servlet-filter.md
Last active July 13, 2018 00:31
Basic-Authentication Servlet Filter
/**
* Some credits to http://stackoverflow.com/a/18363307/771431
*/
public class MyBasicAuthFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
/**
* Socket factory with keep alive setting.
* For using with com.sun.jndi.ldap.LdapCtxFactory add it in the env Hastable:
* env.put("java.naming.ldap.factory.socket", "yourpackage.KeepAliveSocketFactory");
*/
public class KeepAliveSocketFactory extends SocketFactory {
@Override
public Socket createSocket() throws IOException {
Socket socket = new Socket();
@zonia3000
zonia3000 / jsf-custom-panelGroup.md
Last active April 14, 2016 14:51
JSF h:panelGroup with custom HTML tag (very useful for ul/ol tags)

JSF h:panelGroup with custom HTML tag

JSF tag h:panelGroup can be only:

  • a span (setting its attribute layout="span") or
  • a div (setting its attribute layout="block")

There are situations in which you would being able to choose another kind of HTML tag (i.e. to avoid inserting a span/div inside an ul/ol element or to comply with some CSS constraint that result from the usage of CSS/HTML frameworks as Bootstrap).

The following composite component simulates h:panelGroup behavior adding the possibility to set a custom tag.

@zonia3000
zonia3000 / various-jsf-tips.md
Last active August 23, 2016 07:39
Various JSF tips

Various JSF tips

Get named bean by EL from FacesContext

ELContext elCtx = FacesContext.getCurrentInstance().getELContext();
MyBean bean = (MyBean) elCtx.getELResolver().getValue(elCtx, null, "myBean");

Send custom AJAX error response:

@zonia3000
zonia3000 / jsf-validator-vs-converter.md
Last active March 25, 2016 08:49
JSF: h:inputText Validator vs custom Converter

JSF: h:inputText Validator vs custom Converter

Validator method

xhtml:

<h:inputText value="#{myBean.inputValue}" validator="#{myBean.validateInput}" />