Posts

Find duplicates in Postgres table and remove them

 To find all duplicates in table: SELECT name, COUNT( name ) FROM client GROUP BY name HAVING COUNT( name )> 1 ORDER BY name; To remove one: DELETE FROM client a USING client b WHERE a.id < b.id AND a.name = b.name;

Notepad++ Tips

Sometimes you need to remove ids from sql dump. For example: INSERT INTO public.dcicv VALUES (4, 'Benzilpenicilina Benzatínica', 'Antibacterianos', 'Penicilinas'); INSERT INTO public.dcicv VALUES (5, 'Procaína', 'Antibacterianos', 'Penicilinas'); INSERT INTO public.dcicv VALUES (6, 'Benzilpenicilina procaínica', 'Anti-infeciosos',  'Penicilinas'); convert to : INSERT INTO public.dcicv VALUES ( 'Benzilpenicilina Benzatínica', 'Antibacterianos', 'Penicilinas'); INSERT INTO public.dcicv VALUES ( 'Procaína', 'Antibacterianos', 'Penicilinas'); INSERT INTO public.dcicv VALUES ( 'Benzilpenicilina procaínica', 'Antibacterianos', 'Penicilinas'); just do replace regular expression: [0-9]+(\,)

ImageMagick Resize the width, adding a prefix to the same names in current directory under Windows 7

Image
ImageMagick Resize the width, adding a prefix to the same names in current directory under Windows 7: & 'C:\Program Files\ImageMagick-7.0.8-Q16\convert.exe' -strip -thumbnail '250x>' *.jpg -set filename:area "thumb-%t" ./%[filename:area].png Result:  1.jpg --> thumb-1.png 2.jpg --> thumb-2.png 3.jpg --> thumb-3.png 4.jpg --> thumb-4.png

Naviserver Ubuntu16.04 service bootup,config

cd /etc/systemd/system vim naviserver.service ----------------------------------------------------------------- [Unit] Description=NAVISERVER After=network.target [Service] Type=forking PIDFile=/opt/ns/logs/nsd.pid ExecStart=/etc/init.d/naviserver start ExecReload=/etc/init.d/naviserver restart ExecStop=/etc/init.d/naviserver stop [Install] WantedBy=multi-user.target :wq! ----------------------------------------------------------------- cd /etc/init.d/ vim naviserver ----------------------------------------------------------------- #!/bin/sh # /etc/rc.d/rc.naviserver # Start/stop/restart # the NaviServer (nsd) web server. # To make Naviserver start automatically at boot, make this # file executable: chmod 755 /etc/rc.d/rc.naviserver ### BEGIN INIT INFO # Provides:          naviserver # Required-Start:    $all # Required-Stop: # Default-Start:     2 3 4 5 # Default-Stop: # Short-Description: Naviserver ...