{{error}}
{{(quickSearchResults.length>10)?'10+':(quickSearchResults.length)}} {{(quickSearchResults.length==1)?'result':'results'}}
{{result.title}} {{result.timeStamp | mysql2ymd }}
I am sorry, no such article was written yet.
Simple universal HTML client filter
A simple JS script for HTML client-side filtering of nodes:
function filterNodes(jQuerySet,value){
	value=(""+value).toUpperCase();
	var values=value.split(" ");
	var signs=[];
	for(var i=0;i<values.length;i++){
		if(values[i].charAt(0)=='!'){
			signs[i]=1;
			values[i]=values[i].substr(1);
		}
		values[i]=unescape(values[i]);
	}
	var nodes=jQuerySet;
	for(var i=0;i<nodes.length;i++){
		var nodeValue=nodes[i].innerHTML.toUpperCase();
		try{
			nodeValue=nodeValue.replace(/<[^>]+>/g, '');
		}catch(e){}
		$temporaryValue=1;
		if(value!='')
			for(var j=0;j<values.length;j++)
				if(values[j])
					if(signs[j]^(nodeValue.indexOf(values[j])<0)){
						$temporaryValue=false;
						break;
					}
		if($temporaryValue)
			$(nodes[i]).show();
		else
			$(nodes[i]).hide();
	}
}
How to request and generate authentication nonces via emails
Some clues on how to implement a fast ad-hoc authentication mechanism based on the email of the user.
  1. Publish a page where the user may request the ad-hoc token;
  2. On the ad-hoc page request the user to input the email address;
    • To avoid bot spamming you may generate the form field name based on a secret name stored on the server-side session;
    • As a consequence, the submitted form must always come as a response to a pre-exising server session, session that is not preserved using the classical curl libraries used by bots;
  3. An email with the nonce will be sent to the given address;
    • The nonce will be stored only on the server side, so the only way to know it is to open the email - which means that the user has access to the given mail;
  4. The user will put the nonce from mail in form; together with the nonce, the server will keep in session also the generation time;
Advantages:
  • nonce may be short, it does not have to be long and secure;
  • only the server side and the email address owner have access to nonce;
  • nonce cannot be reused if another one has been generated for that given session;
  • the mechanism guarantees that the owner of the mail address is the user of the page;
  • the user does not need any 3rd party credentials authority supplier.
Menu sample:
1 files attached: OpenIdAuthenticationProvider
OpenIdAuthenticationProvider
Emgu.CV video surveillance - part 2: how to keep only relevant images
One big issue in video surveillance is disseminating between relevant images and irrelevant images. For such comparison we need to compute the distance between two images, and for this a first step would be to bring images to only one relevant chanel, as example being:
  • luminosity channel - for comparing high resolution noiseless images;
  • crominance channel - when we have goot luminosity, but it changes over time;
Once we decide on the relevant channel for comparison, the next step is to filter the image (remove the noise). For this task I used the simple erode/dilate method mixed with median smoothing.
Once images are softened, I just compute the norm of the binary difference.
As seen in this code, I do run differences between thumbnails of images (which is much faster than the full image comparison.
Very important is that the value of threshold which is in my case 24 was not chosen randomly, but it is the one that gives best results on images both on day and night time.
To reach this value of 24 I ran tests on samples as following:
  • night time similar images;
  • night time small-difference images;
  • day time similar images;
  • day time small-difference images.
Even though the algorithm seems quite simple, it took me around one week to reach to it, as before I used various much more complex adaptive algorithms depending on other properties of images (including median luminance and noise quantity in image). At the end I reached to this very simple solution that brings the same quality but with much less code and much less complexity.
1 files attached: Campture.cs
Campture.cs
C#-Selenium bridge to automate browser application testing
Depending on the application under test and the technical restrictions you may need to test applications on different platforms. One solution is to use Selenium. However, a huge limitation of Selenium is that windows cannot be reused. In order to automate various browsers my recommended way is to plug Selenium in a host (C#, Java, Python, or whatever else).
Attached is a scripting engine I used to automate with Selenium over C#. As a precondition, you need to import in the project the browser connectors:
  • chromedriver.exe
  • IEDriverServer.exe
The Firefox connector comes out of the box with Selenium.
Another important component is the attached test set class.
This second class is the big thing in application, which will be able to parse files as in main.dms. Or, sample1.dms, and sample2.dms.
5 files attached: SeleniumWrapper.cs TestSet.cs test.dms sample1.dms sample2.dms
SeleniumWrapper.cs TestSet.cs test.dms
#browser ie
#on step.before step_before.js

#timeout 20
#include login.dms

#include client_sim_add-remove.dms
#include client_people.dms
sample1.dms
window.location="http://betalogin.mdmconsole.com";
UNTIL => (''+window.location).match('^http://hidden-url.com/')

##Login > input email, password
$('input#email') <= 'secret@example.com'
$('input#password') <= 'secret-password'
##Login > click Login
$CLICK => $('button:contains(\"Login\")')
##Console > Wait for "Logout" button to appear
UNTIL => $('button:contains(\"Logout\")').length==1
##Console > Log in as
$CLICK => $('button:contains("Log in as")')
##Console > Log in as > roles := client; userId:=SecretUser*
$CLICK => $('input#roles').siblings("img")
$CLICK => $('.x-combo-list-item:contains("Client")')
$CLICK => $('input[name="userID"]').siblings('input[value^="Akela"]')
##Console > Click "Log in"
$CLICK => $('#btnLogin button:contains("Log in")')
sample2.dms
##People
$CLICK => $('#nav-Endusers button:contains("People")')
##People > Add
$CLICK => $('table:contains("Export to CSV") button:contains("Add")')
##People > Add > first_name, last_name, email, owner language, pass1, pass2, Active:=true, Save
$(':contains("Person details") input[name="first_name"]') <= d2a('%EXECUTION_ID%FirstName')
$(':contains("Person details") input[name="last_name"]') <= d2a('%EXECUTION_ID%LastName')
$(':contains("Person details") input[name="email"]') <= d2a('e%EXECUTION_ID%@example.com')
$('#EditPersonWindow input#ownerLanguage') <= 'English'
$('#EditPersonWindow input#pass1') <= d2a('%EXECUTION_ID%')
$('#EditPersonWindow input#pass2') <= d2a('%EXECUTION_ID%')
$('#EditPersonWindow label:contains("Active:")').siblings().find("input") <= true
$CLICK => $('#EditPersonWindow button:contains("Save")')
UNTIL => $('#EditPersonWindow').length==0
C# Emgu.CV video surveillance - part 1: how to capture snapshots every few seconds
A sample application to capture every two seconds a photo with the video camera using Emgu.CV on C#.
1 files attached: EmguCapture.cs
EmguCapture.cs
using Emgu.CV;
using System.Collections;
using Emgu.CV.CvEnum;
using Emgu.CV.Util;
using Emgu.CV.Structure;
using Emgu.CV.Features2D;
using System;
using System.Drawing.Imaging;
using System.IO;
using System.Threading;

namespace ConsoleApplication2
{
	class Program
	{
		static void Main(string[] args)
		{
			if (args.Length!=0){
				if (args[0] == "start")
					CaptureStart();
				if (args[0] == "stop")
					CaptureStop();
			}
			Console.WriteLine("Capture start | stop");
		}
		public static void CaptureStart()
		{
			var signature = "" + new Random().Next();
			Config.set("capture-session", signature);
			Capture c = new Capture();
			c.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1024);
			c.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 768);
			for (;;)
			{
				if (Config.get("capture-session") != signature) return;
				try
				{
					Thread.Sleep(3000);
					var thumbnail = c.QueryGrayFrame();
						Storage.Save(c.QueryFrame());
				}
				catch (Exception e)
				{
					Console.WriteLine(e.StackTrace);
				}
			}
		}
		public static void CaptureStop()
		{
			Config.set("capture-session", "");
		}
	}
}
How to put in Windows the timestamp (year, month, day, hour, and minute) in an environment variable
(for /f "tokens=2,3,4 delims=/ " %i in ('date /t') do set _YMDHM=%k-%j-%i)
(for /f "eol=P tokens=1,2 delims=: " %i in ('time /t') do set _YMDHM=%_YMDHM%-%i-%j)
The final result should be similar to:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\dsorescu>clear

C:\Users\dsorescu>(for /f "tokens=2,3,4 delims=/ " %i in ('date /t') do set _YMD
HM=%k-%j-%i)

C:\Users\dsorescu>set _YMDHM=2013-15-03

C:\Users\dsorescu>(for /f "eol=P tokens=1,2 delims=: " %i in ('time /t') do set
_YMDHM=%_YMDHM%-%i-%j)

C:\Users\dsorescu>set _YMDHM=2013-15-03-04-10

C:\Users\dsorescu>
SSL installation on Apache, and why SSL compression is A SECURITY HOLE
Some examples of how to install on Apache the certificates:
SSLCertificateFile /home/dsorescu/private/html/ssl/sorescu.eu.crt
SSLCertificateChainFile /home/dsorescu/private/html/ssl/sorescu.eu.pem #the CA file
SSLCertificateKeyFile /home/dsorescu/private/html/ssl/sorescu.eu.key
Most of people will also be tempted to enable the SSL comprssion as following:
SSLCompression on
Using compressed SSL poses a security leak very easy to understand and to exploit; the explaination is as following (all entities mentioned below are fictional and meant to ease the understanding of the method):
  1. your internet operator (or the IT department from your work) can listen to your compressed SSL requests (obviously they cannot decrypt them);
  2. the operator will modify your HTTP (non-secure) pages to include a small invisible image as following: <img src='https://dragos-matei.sorescu.eu/scrambled-image-name-freaky-url.png'/>;
  3. the network operator will measure the length of the browser request (the request will contain the cookies and the image fake url in a compressed and encrypted version);
  4. the network operator knows that once the url will contain repeating keywords (including passwords), the compressed SSL request will be shorter.
For this task to be successful, the operator (or your employer) should know a bit about which cookies the target site is using (this is not protected), and they have to use your browser to make lots of requests based on various possible passwords.
A way to ameliorate the speed of detection is to give up the brute force, but use orthogonal and white-noise techniques, which allows the attacker to send few very long requests with random information and see which of the requests is "closer" to your cookie values.
This works on the principle that the size of the compressed text decreases with the similarity of its components.
More details on: Short explanation from TheRegister.co.uk and Security.StackExchange.com.
Easy tool to query for IP details http://whois.net/ip-address-lookup/[IP_VALUE]
Often I was in need to know who is accessing my site. Aside the IP, I needed further information (like country or company owning the IP), and I found the following site very useful: http://whois.net/ip-address-lookup/[IP_VALUE] link.
Sorescu.EU SSL enabled - and how to enable SSL using cPanel for all subdomains
Steps (yes - it works out-of-box with Windows, you Linux geeks!):
  1. First step would be to buy a wildcard certificate, in my case being wildcard.sorescu.eu.pfx; this file should contain both, the private and the public key;
  2. Extract the key from the PFX: openssl pkcs12 -in wildcard.sorescu.eu.pfx -nocerts -out sorescu.eu.key; attention - you must know from before the password to be able to open the PFX; you will also be promted to enter the PEM pass phrase - which you should put it of a different value;
  3. Ensure that sorescu.eu.key was generated;
  4. Decrypt the key by running openssl rsa -in sorescu.eu.key -out sorescu.eu.decrypted.key;
  5. Ensure that sorescu.eu.decrypted.key got created;
  6. IMPORTANT! Now you need to generate the actual certificate, by running openssl pkcs12 -in sorescu.eu.pfx -clcerts -nokeys -out sorescu.eu.crt;
  7. Check that sorescu.eu.crt file got created;
  8. Generate the PEM file using openssl pkcs12 -in wildcard.sorescu.eu.pfx -cacerts -nokeys -out cabundle.pem; sincerely I don't understand much from this extension, only that it seems to contain the certification chain of the certificate;
  9. Check that the PEM file is created;
  10. Inside the cPanel open the SSL section;
  11. Go to Certificates (CRT);
  12. Once you install the CRT, you get a message similar to Installed Certificates for the domain(s): *.sorescu.eu (auto-detected);
  13. From the SSL home page in cPanel go to Activate SSL on Your Web Site (HTTPS);
  14. In the Certificate (CRT), Key (KEY), Ca Bundle (CABUNDLE) paste the text contents of the following files: sorescu.eu.crt, sorescu.eu.key, cabundle.pem;
  15. Open the web page.
I want to thank to http://www.mickgenie.com/cpanel-how-to-install-ssl-with-pfx-file/ for figuring me out how manage it.
Please also see below:
Sorescu technical Knowledge Base now supports OSSD fast search in Google Chrome
Now, once you visited KB.Sorescu.EU for the first time, you may instantly search the site via the Chrome's search extensions just by typing K, B, and [TAB] followed by your search query.
An example is below:

The technology used is OSSD Open Search standard; implementation has been done in two steps:
  • The home file contains the link to the OSSD file;
  • The second step was to supply the browser with the OSSD file.
Have a nice browsing experience!
2 files attached: header.html OSSD.xml
header.html
<link title="Sorescu KB" type="application/opensearchdescription+xml" rel="search" href="http://kb.sorescu.eu/ossd"/>
OSSD.xml
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
	<ShortName>Sorescu KB</ShortName>
	<Description>Sorescu technical knowledge base</Description>
	<InputEncoding>UTF-8</InputEncoding>
	<Image height="16" width="16" type="image/x-icon">http://kb.sorescu.eu/favicon.ico</Image>
	<Url type="text/html" template="http://kb.sorescu.eu/search/{searchTerms}"/>
</OpenSearchDescription>