How to load Classes at runtime from a folder or JAR?

The following code loads all classes from a JAR file. It does not need to know anything about the classes. The names of the classes are extracted from the JarEntry. JarFile jarFile = new JarFile(pathToJar); Enumeration<JarEntry> e = jarFile.entries(); URL[] urls = { new URL(“jar:file:” + pathToJar+”!/”) }; URLClassLoader cl = URLClassLoader.newInstance(urls); while (e.hasMoreElements()) { … Read more

Calculating Page Load Time In JavaScript

Why so complicated? When you can do: var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart; If you need more times check out the window.performance object: console.log(window.performance); Will show you the timing object: connectEnd Time when server connection is finished. connectStart Time just before server connection begins. domComplete Time just before document readiness completes. domContentLoadedEventEnd Time after DOMContentLoaded event … Read more

Capture iframe load complete event

<iframe> elements have a load event for that. How you listen to that event is up to you, but generally the best way is to: 1) create your iframe programatically It makes sure your load listener is always called by attaching it before the iframe starts loading. <script> var iframe = document.createElement(‘iframe’); iframe.onload = function() … Read more

changing source on html5 video tag

I hated all these answers because they were too short or relied on other frameworks. Here is “one” vanilla JS way of doing this, working in Chrome, please test in other browsers: var video = document.getElementById(‘video’); var source = document.createElement(‘source’); source.setAttribute(‘src’, ‘http://techslides.com/demos/sample-videos/small.mp4’); source.setAttribute(‘type’, ‘video/mp4’); video.appendChild(source); video.play(); console.log({ src: source.getAttribute(‘src’), type: source.getAttribute(‘type’), }); setTimeout(function() { video.pause(); … Read more

Do zombies exist … in .NET?

Is there a clearer definition of a “zombie thread” than what I’ve explained here? Seems like a pretty good explanation to me – a thread that has terminated (and can therefore no longer release any resources), but whose resources (e.g. handles) are still around and (potentially) causing problems. Can zombie threads occur on .NET? (Why/Why … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)