Paul's Programming Notes PostsRSSGithub

Jquery Slideup Jerking Effect In IE9

This website has code to help get rid of the jerking effect on Jquery SlideUp in IE9: https://siderite.dev/blog/jquery-slideup-flickers-in-internet.html

You just add this code after you include your Jquery library:

(function(){
// Define overriding method.
jQuery.fx.prototype.hide = function(){

// Remember where we started, so that we can go back to it later
this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
this.options.hide = true;

// Begin the animation
this.custom(this.cur(), 1);
}
})();

Raspberry Pi - No Ethernet Caused By Charger

I was using a cheap USB charger, but I couldn’t get my Raspberry Pi to connect over Ethernet. The ethernet lights showed no link.

Turned out the charger couldn’t supply enough current. The Model B needs a 5V micro-USB supply that can deliver at least 700mA for the board alone, and more with anything plugged in; plenty of phone chargers only put out 500mA. When the Pi undervolts it shuts off its USB ports to stay stable, and on the Model B the Ethernet runs through that same USB chip, so it drops right along with them. Swapping in a Motorola OEM charger fixed it. I have the Model B, Rev 2.0 board with 512MB RAM.

LDAP_ADD PHP - Object Class Violation

If you are trying to use php’s ldap_add to add an user and are getting an object class violation, try to copy all the fields of a working user exactly. Most likely you are missing some of the required fields of the objectclass you are trying to add.

Reading RFID With Raspberry Pi (or any linux device) + Reader

I’m using the following Parallax USB RFID reader: http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/28140-28340-RFIDreader-v2.2.pdf

First you will need to ensure you have PySerial installed by trying to import PySerial while running Python’s IDLE. If you receive an error:

Install PySerial:

  1. Install python’s setuptools: apt-get install python-setuptools
  2. Install PySerial: pip install pyserial

Once you have PySerial installed, open IDLE again and use the following code to see output from the reader:

Why didn’t ser.read(12) return the same unique identifier as what is written on the fob?:

  • If the key on the card says 30788590 and the reader returns 3501D5CBEE. The “1D5CBEE” part is the card number. Try going from the card number in DEC to HEX it in the windows calculator while it’s in scientific mode if you don’t believe me.

"margin-left: auto;" and "margin-right: auto;" Not Working In IE8

To get something centered within a div in IE8, it requires doing something unusual. I wasn’t able to get the “display: block;” trick working. But this worked:

#super-wrap { position: absolute; width: 100%; text-align: center; }
#page-wrap { position: relative; width: 970px; margin: auto auto; }

I had to do this to get the InfoGrid (http://css-tricks.com/examples/InfoGrid/) to center in IE8. The div with the ID of #page-wrap already exists, but the super-wrap div needs to be created outside of the page-wrap div.

Using "nth-of-type" with IE8

IE8 apparently doesn’t support the CSS selector “nth-of-type”.

You can fix it by adding this script to your page: https://github.com/keithclark/JQuery-Extended-Selectors/blob/master/jquery-extra-selectors.js

You will also need to add the following script to the bottom of your page (of course you will need to swap the numbers with your own):

$("div:nth-of-type(1)").css("background", "#b44835");

I used this to fix an IE8 compatibility issue with something called InfoGrid: http://css-tricks.com/examples/InfoGrid/

PHP - Generate SSHA (sha1) Password For LDAP User

Updated 2026-08-07: the snippet I originally posted produced an unsalted {SHA} hash despite the {SSHA} in the title. Replaced it with the password modify extended operation.

This is what I originally posted here, and it was wrong:

$info['userpassword'][0] = "{SHA}" . base64_encode(sha1("pass", TRUE));

That produces {SHA}, a plain unsalted SHA-1, not the {SSHA} the title promises. In the RFC 2307-style schemes OpenLDAP uses, {SHA} is base64(SHA-1(password)), while {SSHA} hashes the password with a random salt and stores that salt alongside the digest, as slappasswd documents. Skipping the salt means every user who picks the same password ends up with the same hash, so one lookup table cracks all of them at once.

The better fix is to stop generating the hash in PHP. The LDAP password modify extended operation (RFC 3062) exists so the client never has to pick a storage scheme. You hand the server the new password and it applies whatever hash it’s configured for:

ldap_exop_passwd($ldap, "uid=someone,ou=people,dc=example,dc=com", "", $newPassword);

PHP has had that wrapper since 7.2. The password travels in the clear inside the request, so run it over LDAPS or StartTLS, and you can confirm the server supports the operation by reading supportedExtension on the root DSE and looking for 1.3.6.1.4.1.4203.1.11.1.

Doing it this way makes the scheme a server setting instead of something frozen into application code. OpenLDAP calls that setting olcPasswordHash (password-hash in the older slapd.conf), and it defaults to {SSHA}. OpenLDAP also ships an argon2 module adding an {ARGON2} scheme, which is a far better choice than anything built on SHA-1. Debian has it in slapd after 2.5.4+dfsg-1, where it needs a moduleload argon2. Changing that directive re-hashes new passwords with no application deploy.

If you’re stuck generating the value yourself, salt it:

$salt = random_bytes(8);
$userPassword = "{SSHA}" . base64_encode(sha1($password . $salt, true) . $salt);

That produces a correct {SSHA}. It’s still SHA-1, which is why I’d rather let the server do it.