CSS – How to keep footers at the bottom of the page

How to keep footers at the bottom of the page?

HTML:
<div id="container"> <div id="header"></div> <div id="body"></div> <div id="footer"></div> </div>
CSS:
html, body { margin:0; padding:0; height:100%; }
#container { min-height:100%; position:relative; }
#header { background:#ff0; padding:10px; }
#body { padding:10px; padding-bottom:60px; /* Height of the footer */ }
#footer { position:absolute; bottom:0; width:100%; height:60px; /* Height of the footer */ background:#6cf; }

Resource:
https://pixel2pixeldesign.com/footers-bottom-page/



Processing – Asynchronous load web image

How to load an image from an URL asynchronously from the web?

When you use the regular loadImage() function, sometimes it ‘hangs’ while fetching an image from the web.
The following class has a timeout parameter, so it will give up after an x-amount of seconds.

Add to your sketch:

// ASYNC IMAGE LOADER
WebImageLoader webImageLoader;

void setup() {
(...)
webImageLoader = new WebImageLoader(this);
(...)
}

The loader class:

/**************************************************************************
 *
 *  ASYNC IMAGE LOADER
 *
 **************************************************************************/
boolean loaderDebug = false;
boolean done;

/**************************************************************************
 *
 *  LOADER CLASS
 *
 **************************************************************************/
class Loader extends Thread {
  PImage p;
  PApplet parent;
  String f;

  /************************************************************************
   *
   *  CONSTRUCTOR
   *
   ************************************************************************/
  Loader(PApplet parent) {
    this.parent = parent;
    done = true;
  } // Loader()


  /************************************************************************
   *
   *  LOAD
   *
   ************************************************************************/
  void load(String file) {
    if (done == true) {
      this.f = file;
      done   = false;
    } // if (this.done == true)
  } // load()


  /************************************************************************
   *
   *  RUN
   *
   ************************************************************************/
  public void run() {
    if (done == false) {
      if (loaderDebug) println("Loader loading: " + this.f);
      try {
        this.p = this.parent.loadImage(this.f);
      } 
      catch(Exception e) {
        e.printStackTrace();
      };

      if (this.p != null) {
        if (loaderDebug) println(this.p.width + " " + this.p.height);
      }
      done = true;
      if (loaderDebug) println("Loader done");
    } // if (this.done == false)
  } // run()
} // Loader


/**************************************************************************
 *
 *  ASYNC LOAD IMAGE CLASS
 *
 **************************************************************************/
public class WebImageLoader {
  PApplet parent;

  /************************************************************************
   *
   *  CONSTRUCTOR
   *
   ************************************************************************/
  WebImageLoader(PApplet _parent) {
    parent = _parent;
  } // WebImageLoader()


  /************************************************************************
   *
   *  LOAD THE IMAGE
   *
   ************************************************************************/
  PImage loadWebImage(String file, int timeout) {
    Loader ldr = new Loader(parent);
    ldr.start();
    ldr.load(file);
    long load = System.currentTimeMillis();

    while (true) {
      if (loaderDebug) println("Checking: "+ done);

      if (done == true) {
        if (loaderDebug) println("Returning image");
        return ldr.p;
      } // if (ldr.done == true)

      if ((System.currentTimeMillis() - load)  > timeout) {
        //if (loaderDebug) println("Timeout");
        return null;
      } // if ((System.currentTimeMillis() - load)  > timeout)

      try {
        parent.delay(50); // 500
      } 
      catch(Exception e) {
      } // try
    } // while (true)
  } // loadWebImage()
} // WebImageLoader

Load an image:

PImage img = webImageLoader.loadWebImage(url, 5000);
with url is the url of the image; 5000 is the timeout in millis

Adapted from:
https://forum.processing.org/one/topic/loadimage-timeout.html


Processing – Validate a date

How to validate a date in Processing?

boolean isValidDate(String _date) {
  try {
    DateFormat df = new SimpleDateFormat("dd-M-yyyy");
    df.setLenient(false);
    df.parse(_date);
    return true;
  } 
  catch (Exception e) {
    return false;
  } // try
} // isValidDate()




Processing Java – “WARNING: Could not open/create prefs root node”

How to get rid of the “Could not open/create prefs root node…” warning?

  • Go into your Start Menu and type regedit into the search field
  • Navigate to path HKEY_LOCAL_MACHINE\Software\JavaSoft
    (Windows 10 seems to now have this here: HKEY_LOCAL_MACHINE\Software\WOW6432Node\JavaSoft)
  • Right click on the JavaSoft folder and click on New -> Key
  • Name the new Key Prefs and everything should work


WordPress – Reset password in database

How to reset a WordPress password directly in the database (using PHPMyAdmin)?

METHOD 1

Go to
https://www.md5hashgenerator.com/
and calculate the MD5 hash for the password you want to use.

Open the WordPress users table (in PHPMyAdmin) wp-users and paste the MD5 hash into your user_pass field.

 

METHOD 2 (SNEAKY ONE!)

  • Open the WordPress users table (in PHPMyAdmin) wp-users.
  • Select a user with Administrator rights.
  • Back up the (encrypted) password and email address of that user in a text file.
  • Change the email address to your own email address.
  • Go to the WP login page and click the ‘Lost your password?’ link.
  • Enter your own email address (the one you entered in the database).
  • Click the ‘reset password’ link in the email that you receive from WordPress.
  • Enter a new password and you are in!
  • Create a new user for yourself, with Administrator rights.
  • In PHPMyAdmin, restore the password and email for the user you abused.
  • DONE 😉

Resource:
http://www.wpbeginner.com/beginners-guide/how-to-reset-a-wordpress-password-from-phpmyadmin/