All posts by talexone

Webmin sous Debian

Ajouter la clé GPG du dépôt à votre système en saisissant dans un terminal :

wget -O- http://www.webmin.com/jcameron-key.asc | sudo apt-key add -

Modifiez vos sources de logiciels pour y ajouter un des dépôt suivants:

sudo echo 'deb http://download.webmin.com/download/repository sarge contrib' >> /etc/apt/sources.list 

sudo apt-get update

sudo apt-get install webmin

Changer le mot de passe :

sudo /usr/share/webmin/changepass.pl /etc/webmin root votre_mot_de_passe

Redémarrer le service webmin :

sudo service webmin restart

Vous pouvez vous connecter à partir d’un navigateur en y insérant au choix l’adresse :

http://votre_nom_de_serveur:10000/
https://votre_nom_de_serveur:10000/

Customize Dahua PSS Hotkeys

This will show you how to customize the Hotkeys for Dahua PSS software.
Locate the file named “UserLogin.ini” in the PSS program path.
The Hotkeys are in the “[ShortKey]” section of the file.

Explanation of the Values

• ShortKeyCount – Total number of hotkeys
• ShortKey_ItemName1 – Hotkey 1 Explanation (not important)
• ShortKey_ItemKey1 – Hotkey 1 Combination Description (not important)
• ShortKey_KeyValue1 – Hotkey 1 Value (important)
• ShortKey_KeyModifiers1 – Hotkey 1 Modifier (important)

In the case of CTL+F, CTL is the Modifier, F is the value.
So if you want to use the F key to switch to full screen, instead of CTL+F ..

ShortKey_ItemName1=Real Display Full Screen
ShortKey_ItemKey1=F
ShortKey_KeyValue1=70
ShortKey_KeyModifiers1=0

Note: just changing the ItemKey alone will do nothing.
Also, disable UAC before making changes to the INI file.

A=65, B=66 …. F=70 …. W=87, etc
Here is a small FREE tool to get keycodes:
Download GetKeycodes

Optionally you could change the Hotkeys from within PSS.
Run PSS and go to “Config”, “Options”, “Hotkeys”.

Workaround for installing HibernateSynch on Eclipse Luna

During installation of HibernateSynch plugin on Eclipse Luna from http://hibernatesynch.sourceforge.net/ I getting a “Failed to prepare partial IU” error.

I could solve this error by installing “Eclipse 2.0 Style Plugin Support” from “Eclipse Tests, Examples, and Extras” of “The Eclipse Project Updates – http://download.eclipse.org/eclipse/updates/4.4”.

So go to Help -> Install New Software…, then choose “The Eclipse Project Updates – http://download.eclipse.org/eclipse/updates/4.4” from the “Work with” list and then in the “Eclipse Tests, Examples, and Extras” category check “Eclipse 2.0 Style Plugin Support” and install it. After restarting Eclipse, install HibernateSynch again and this time the installation will succeed.

Using PNG images for buttons in Lazarus/FPC from resource script .RC or compiled resource file .RES

Some components already has a method LoadFromResource to load picture from resource, but it works only with bitmap resources. And calling it for png images will rise an “EResNotFound” exception.

So here is my solution.
First create a resource script file with .RC extention:

ADD_PNG    RCDATA "images\\add.png";
EDIT_PNG   RCDATA "images\\edit.png";
REMOVE_PNG RCDATA "images\\remove.png";

Then add this file to the unit with an option {$R}


implementation

{$R filename.rc}

Create a procedure to simplify calling :

procedure PngImageFromResources(APicture: TPicture; AResourceName: string);
var
  png: TPNGImage;
  rs: TResourceStream;
begin
  png := TPNGImage.Create;
  rs := TResourceStream.Create(HInstance, AResourceName, RT_RCDATA);
  try
    png.LoadFromStream(S, S.Size);
    APicture.Graphic.Assign(png);
  finally
    png.Free;
    s.Free;
  end; 
end;

And to finish call a procedure with a TPicture object and resource name as parameters:


 PngImageFromResources(BitBtn1.Glyph.Picture, 'ADD_PNG');

Algorithme CRC – 16 – CCITT

Un autre CRC dans ma bibliothèque est le CRC-16-CCITT ou plus court le CRC-CCITT, je suis tombé sur son utilisation dans
un tourniquet automatique. On peux le retrouver dans X.25, V.41, HDLC FCS, XMODEM, Bluetooth, PACTOR, SD et autres.

Utilisation: crc := CRC_CRTITT(packet);

unit CRC_CCITT;

interface

const
P_CCITT= $1021;
function CRC_CRTITT(packet : tbytes):word;

implementation

var
crc_table: array[0..255] of word;
crc_table_init: boolean = false;

procedure SendByte(B: Byte; var crc: word);
var
tmp, c: word;
begin
c  := $00ff and B;

tmp := (crc shr 8) xor c;
crc := (crc shl 8) xor crc_table[tmp];
end;

procedure MakeTable;
var i, j: Integer;
crc, c: word;
begin
for i := 0 to 255 do begin
crc := 0;
c := i shl 8;
for j := 0 to 7 do begin
if ((crc xor c) and $8000) > 0  then crc := ( crc shl 1 ) xor P_CCITT
else crc := crc shl 1;
c := c shl 1;
end;
crc_table[i] := crc;
end;
crc_table_init := TRUE;
end;

function CRC_CRTITT(packet : tbytes):word;
var
i: integer;
crc: word;
Begin
crc := 0;
if not crc_table_init then MakeTable;

for i := 0 to length(packet)-1 do
begin
SendByte(packet[i], crc);
end;
CRC_CRTITT := CRC;
end;
end.

Algorithme CRC – 16 – IBM

Voici le premier exemple dans la catégorie “CRC Libs”. Un algorithme de calcul de CRC IBM 16bits.
On retrouve cette algorithme dans des protocoles comme Bisync, Modbus, USB, ANSI X3.28, SIA DC-07
et beaucoup d’autres. Il est connu aussi sous le nom CRC-16 et CRC-16-ANSI.

len: la taille du tableau
data: le tableau avec les données

Free Pascal:

function CRC_16_IBM(len: longword; data: TBytes): integer;
var
   num1, i: longword;
   num2: byte;
   j: integer;
begin
  num1 := 0;
  num2 := 0;
  for i := 0 to len-1 do
  begin
    num2 := data[i];
    if i=2 or i=3 then num2 := 0;
    num1 := num1 xor num2;
    for j := 0 to 7 do
      if (num1 and 1) > 0 then
        num1 := (num1 >> 1) xor $a001
      else
        num1 := num1 >> 1;
  end;
  result := num1 and $ffff;
end;   

C#:

public static ushort CRC_16_IBM(uint len, byte[] data)
        {
            uint num1 = 0;
            byte num2 = 0;
            for (uint i = 0; i < len; i++)
            {
                num2 = data[i];
                switch (i)
                {
                    case 2:
                    case 3:
                        num2 = 0;
                        break;
                }
                num1 ^= num2;
                for (uint j = 0; j < 8; j++)
                {
                    if ((num1 & 1) > 0)
                    {
                        num1 = (num1 >> 1) ^ 0xa001;
                    }
                    else
                    {
                        num1 = num1 >> 1;
                    }
                }
            }
            return (ushort)(num1 & 0xffff);
        }