Author Archives: Saïd

About Saïd

Software developer.

How much time needed to transfer a file

I need to estimate the time required to transfer a file, here below: The file is 1000M and the transfer rate is 100MB/S, Amount to transfer / transfer rate = time to transfer, so 1000/100 = 10 The time needed … Continue reading

Posted in General | Leave a comment

Git: Recover a deleted file

Hi, To get a deleted file from git (whatever the reason could be), there the command: file=”filepath” git checkout $(git rev-list -n 1 HEAD — “$file”)^ — “$file” Source:

Posted in General | Leave a comment

Postgresql-Get the number of rows affected

You will find a way below to get the number of rows affected by an UPDATE or a DELETE statement.   CREATE FUNCTION update_foobar(id INT, field1 VARCHAR(40)) RETURNS INTEGER LANGUAGE plpgsql AS $$ DECLARE — some variables declarations BEGIN — … Continue reading

Posted in General | Leave a comment

Setup sftp server on debian8 (chroot)

Let’s start by: su – groupadd sftp_users usermod -G sftp_users my_usernamesu – groupadd sftp_users usermod -G sftp_users my_username Then: emacs /etc/ssh/sshd_config   # Search the line below and replace it Subsystem sftp /usr/lib/openssh/sftp-server # by this one Subsystem sftp internal-sftp … Continue reading

Posted in Server, SFTP | Leave a comment

Interesting link 1

Posted in General | Leave a comment

iterate over files in directory

To do not forget: FILES=/path/to/* for f in $FILES do filename=${f##*/} echo $filename done More informations:

Posted in Shell | Leave a comment

shell variable to execute a command

To do not forget: => variable=$(my_commands) json_files=$(find . -name “*.json”) echo $json_file

Posted in Shell | Leave a comment

SQL – From timestamptz A to timestamptz B

For PostgreSQL (tested on 9.4) CREATE TABLE tests(id serial not null, created_on timestamptz); INSERT INTO tests (created_on) VALUES (now()); 2016-02-16 19:26:13.823126-05 I guess you have configured your timezone in your postgresql.conf file. I have for information ‘America/Toronto’. SELECT created_on  AT … Continue reading

Posted in Database, SQL | Leave a comment

shell – code de retour par une commande

Comment lire le code de retour d’une commande comme pwd ? chaque commande executée vous renverra un code d’erreur situé entre 0 et 255. 0 pour opération réussie, sinon toute autre chiffre signifiera qu’une erreur s’est déroulée lors de l’exécution. … Continue reading

Posted in General | Leave a comment

shell – La commande read

La commande read lit l’entrée standard et affecte à la variable passé en paramètre la valeur: ~ read variable_1 foobar ~ echo $variable_1 ~ foobar Si vous voulez que le premier mot soit stocké dans la variable_1 et que le … Continue reading

Posted in Shell, Terminal | Leave a comment