Wednesday, 16 August 2017

MS Access: fancy InStr function

MS Access is a pretty good database included within Office Pro.


The problem
I have tables with a list of Linux packages installed on several servers, one table per server. I want a table with all the packages common to all servers, and for each package (ex: audit-libs-python-1.8-2.el5), the package root (audit-libs-python) and the version (1.8-2.el5).


Step 1: selecting the common packages


SELECT DISTINCT Srv1.Package
FROM Srv1, Srv2, Srv3, Srv4
WHERE Srv1.Package = Srv2.Package
and Srv2.Package = Srv3.Package
and Srv3.Package = Srv4.Package;



Step 2: extracting the package root and version
Package versions are not always written in a similar way. Some examples:
Package                Root        Version
anacron-2.3-45.el5     anacron     2.3-45.el5
aspell-en-6.0-3        aspell-en   6.0-3
bzip2-1.0.3-6.el5_5    bzip2       1.0.3-6.el5_5
db4-4.3.29-10.el5_5.2  db4         4.3.29-10.el5_5.2


However, the version starts with an hyphen (-) followed by a digit (0 to 9). Unfortunately, MS Access doesn't allow the use of Regex (regular expressions).
To overcome this, I replaced all digits by a special character (#) and then searched for the position of "-#"; the substring before this position is the package root, the one after is the version.


SELECT Package,
left(Package,instr(Package,"-")+
 instr(
  Replace(
   Replace(
    Replace(
     Replace(
      Replace(
       Replace(
        Replace(
         Replace(
          Replace(
           Replace(
mid(Package,instr(Package,"-")),"9","#"),
          "8","#"),
         "7","#"),
        "6","#"),
       "5","#"),
      "4","#"),
     "3","#"),
    "2","#"),
   "1","#"),
  "0","#"),
 "-#")-2) as PackageRoot,

mid(Package,instr(Package,"-")+
 instr(
  Replace(
   Replace(
    Replace(
     Replace(
      Replace(
       Replace(
        Replace(
         Replace(
          Replace(
           Replace(mid(Package,instr(Package,"-")),"9","#"),
          "8","#"),
         "7","#"),
        "6","#"),
       "5","#"),
      "4","#"),
     "3","#"),
    "2","#"),
   "1","#"),
  "0","#"), "-#")) as PackageVersion


FROM [Common packages];


Sure that writing a VBA function might do the trick as well, but I wanted a SQL version.


Wednesday, 9 August 2017

The 2044 Is Back

Long time ago, the SSM 2044 4-Pole Voltage Controlled Filter was everywhere. The chip was designed by Dave Rossum (E-MU).
Its characteristic sound could be heard from different synths: Crumar Bit 01, most EMU products, Korg Mono/Poly, Polysix and Trident (Mk I and Mk II), Octave Plateau Voyetra 8 (used by Eurythmics), PPG Wave (used by Tangerine Dream) and many others.


However, Solid State Micro Technology for Music is long ago gone, and SSM 2044 are now rare to find - mostly from dismantled synths - and, of course, expensive.


Hopefully, Dan Parks, a former SSM employee, has decided to recreate the legendary filter with his company, Sound Semiconductor.
The new filter is named SSI2144, and the datasheet is here: http://soundsemiconductor.com/downloads/ssi2144datasheet.pdf

Monday, 16 January 2017

My first SVG

SVG stands for Scalable Vector Graphics. It's a pretty common type of image.

Why?

For my project (recreation of an MPG-80), I need to cut a sheet of metal. Because the cut has to be precise, I choosed to use a laser cutting service. To do so, I need to produce a file (SVG) which represents the path of the laser beam.

My first idea was to vectorize with Inkscape the file I created with Gimp:

Gimp -> PNG file -> Inkscape -> SVG file -> FreeCAD

The result was poor, because the vectorization process created a lot of path (above 2000, whereas I have only 140 objects).

I definitely needed a more precise process. The idea was to create the SVG from scratch:
1- precisely measuring the coordinates of all the objects (holes)
2- creating a SVG file from scratch with Inkscape
3- importing the file in FreeCAD

Fortunately, all the objects I need to cut  boxes, circles and paths (shapes bazed on Bezier curves) and all are symmetrical around vertical and horizontal axis (top is symmetrical to bottom, left to right). So with Gimp, I measured precisely the coordinates of the centers of all objects. I ended with a LibreOffice spreadsheet.

 

 First try...

My attempt to created the SVG with Inkscape went nowehere. Happily, I quick search on Google shows writing a SVG file is rather simple. Here is my first SVG:

  <svg height="100" width="100">
    <circle cx="100" cy="100" r="100" style="fill:rgb(192,192,255);stroke:none;stroke-width:1" />
    <rect x="0" y="0" width="40" height="40" style="fill:rgb(147,147,255);stroke:none;stroke-width:1" />
    <rect x="16" y="16" width="35" height="35" style="fill:rgb(127,127,245);stroke:none;stroke-width:1" />
    <rect x="32" y="32" width="27" height="27" style="fill:rgb(107,107,235);stroke:none;stroke-width:1" />
    <rect x="48" y="48" width="17" height="17" style="fill:rgb(87,87,225);stroke:none;stroke-width:1" />
  </svg>

The result is:

Full documentation available here: https://developer.mozilla.org/en-US/docs/Web/SVG

The spreasheet

For my project, I need to cut 3 sheets: the casing (metal, 1.3 mm), a plastic sheet (lexan) containg the silkscreen, and another metal sheet holding the PCB. The need for 2 metal sheets is leaded to the fact by buttons are enclosed between the two sheets. The coordinate set is differents for each sheet.

In my spreasheet, the columns were:
A: Object Id (unused)
B: Object Label (unused)
C: Object Type on sheet 1 & 2: rect, circle or path
D: Object Type on sheet 3: rect, circle or path
E: Object width in mm
F: Object height in mm
G: Object absolute x in mm
H: Object absolute y in mm
I:  Object x relative to the casing (identical to G)
J:  Object y relative to the casing (identical to H)
K: SVG code for the objects, relative to the casing
L: Object x relative to the silkscreen
M: Object y relative to the silkscreen
N: SVG code for the objects, relative to the silkscreen

In column K, I created a formula to generate all the paths:
="<" & $C4 &
     IF($C4="rect",
  " x=""" & ROUND(Params.$B$1*(L4-$E4/2),3) & """" &
  " y=""" & ROUND(Params.$B$1*(M4-$F4/2),3) & """" &
  " width=""" & ROUND(Params.$B$1*($E4),3) & """" &
  " height=""" & ROUND(Params.$B$1*($F4),3),
     IF($C4="circle",
  " cx=""" & ROUND(Params.$B$1*(L4),3) & """" &
  " cy=""" & ROUND(Params.$B$1*(M4),3) & """" &
  " r=""" & ROUND(Params.$B$1*($F4/2),3),
     IF($C4="path",
  " d=""M" & ROUND(Params.$B$1*(L4-$E4/2),3) & "," & ROUND(Params.$B$1*(M4-$F4/2+Params.$B$2),3) &
  " C" & ROUND(Params.$B$1*(L4-$E4/2),3) & "," & ROUND(Params.$B$1*(M4-$F4/2),3) &
   " " & ROUND(Params.$B$1*(L4+$E4/2),3) & "," & ROUND(Params.$B$1*(M4-$F4/2),3) &
   " " & ROUND(Params.$B$1*(L4+$E4/2),3) & "," & ROUND(Params.$B$1*(M4-$F4/2+Params.$B$2),3) &
  " L" & ROUND(Params.$B$1*(L4+$E4/2),3) & "," & ROUND(Params.$B$1*(M4+$F4/2-Params.$B$2),3) &
  " C" & ROUND(Params.$B$1*(L4+$E4/2),3) & "," & ROUND(Params.$B$1*(M4+$F4/2),3) &
   " " & ROUND(Params.$B$1*(L4-$E4/2),3) & "," & ROUND(Params.$B$1*(M4+$F4/2),3) &
   " " & ROUND(Params.$B$1*(L4-$E4/2),3) & "," & ROUND(Params.$B$1*(M4+$F4/2-Params.$B$2),3) &
   " L" & ROUND(Params.$B$1*(L4-$E4/2),3) & "," & ROUND(Params.$B$1*(M4-$F4/2+Params.$B$2),3), "" )))
 & """ " &Params.$B$3&" />"


Where Params.$B$1 contains a scaling ratio (90*177/(25.4*270)=2.3228346457) and Params.$B$2 contains a rounding factor for the path objects.
This gave the following result (abstract):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="1012.756" height="411.142" xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    version="1.1"
    baseProfile="full">

<rect x="50.998" y="358.762"
    width="25.296"

    height="12.311"
    style="fill:#000000;fill-opacity:1;
        fill-rule:evenodd;stroke:none;
        stroke-width:1px;stroke-linecap:butt;
        stroke-linejoin:miter;stroke-opacity:1" />
<circle cx="63.646" cy="347.264" r="3.484"
    style="fill:#000000;fill-opacity:1;
        fill-rule:evenodd;stroke:none;
        stroke-width:1px;stroke-linecap:butt;
        stroke-linejoin:miter;stroke-opacity:1" />
...
<path d="M115.213,206.616
    C115.213,201.97 123.343,201.97 123.343,206.616
    L123.343,286.754
    C123.343,291.4 115.213,291.4 115.213,286.754
    L115.213,206.616"
    style="fill:#000000;fill-opacity:1;
        fill-rule:evenodd;stroke:none;
        stroke-width:1px;stroke-linecap:butt;
        stroke-linejoin:miter;stroke-opacity:1" />
...


Nice! The fact I had to repeat the style tag on every line is due to a bug when importing in FreeCAD.

The overall result is the following:


A closer look:


In FreeCAD, I could create the casing:

Monday, 31 October 2016

Visio 2010: On connectors, how to align the text alongside the path

On Visio 2010, the text on the connector is always horizontal by default.

When the Visio becomes crowdy, it might be useful to set the text alongside the connector path.
On, in a more general way...
 

How to...

In the option menu, enable the Developper Mode

Now you can left-click on any link to display the ShapeSheet

In the ShapeSheet, go to the Text Transform section



In the TxtAngle setting, replace the current angle (0 deg) by this formula:
=ANGLEALONGPATH(Geometry1.Path,1)+IF(COS(ANGLEALONGPATH(Geometry1.Path,1))>=0,0,180°)


Friday, 28 October 2016

Comprendre les tentatives d'hameçonnage (phishing)

Pour ne pas tomber dans le piège...

Je reçois depuis quelques jours des courriels très bien faits m'invitant à consulter mon compte Paypal ou m'indiquant qu'un colis n'a pu être délivré par UPS. Et le hasard fait que je reçois ce courriel justement le lendemain d'un achat.

Ces courriels sont faux et ne sont que des tentatives d'hameçonnage (phishing) afin de récolter des informations personnelles.

Vers où veut-on m'amener ?

En passant la souris sur les liens (SANS CLIQUER !), des détails s'affichent en bas de l'écran. Le lien nous amène vers epl.paypal-communication.com/... ou epl.ups-delirery.com/...


Alors, des vrais ou des faux ?

Les noms de dommaines sont gérés de manière internationale, en collaboration entre les pays. Tout en haut de la pyramide se trouve un organisme américain, l'ICANN.

Pour vérifier un nom de domaine, on peut recourir au service whois de l'ICANN.

Est-ce que UPS est vraiment UPS ?

Interrogeons l'ICANN...
https://whois.icann.org/en/lookup?name=ups.com

La réponse nous donne:
Contact Information

Registrant Contact
Name: Domain Administrator
Organization: United Parcel Service of America, Inc.
Mailing Address: 340 Macarthur Blvd, Mahwah NJ 07630 US
Phone: +1.2018282480
Ext:
Fax:
Fax Ext:
Email:internet@ups.com

Admin Contact
Name: Domain Administrator
Organization: United Parcel Service of America, Inc.
Mailing Address: 340 Macarthur Blvd, Mahwah NJ 07630 US
Phone: +1.2018282480
Ext:
Fax:
Fax Ext:
Email:internet@ups.com

Tech Contact
Name: Domain Administrator
Organization: United Parcel Service of America, Inc.
Mailing Address: 340 Macarthur Blvd, Mahwah NJ 07630 US
Phone: +1.2018282480
Ext:
Fax:
Fax Ext:
Email:internet@ups.com

C'est bien UPS.

Par contre, si on interroge l'ICANN au sujet de ups-delivery.com...
https://whois.icann.org/en/lookup?name=ups-delivery.com

La réponse est bien différente...

Contact Information

Registrant Contact
Name: hui liu
Organization: liuhui
Mailing Address: jinggangshan road 103,,, ji an shi jiang xi 343000 CN
Phone: +86.7968345588
Ext:
Fax: +86.7968345588
Fax Ext:
Email:285997125@qq.com

Admin Contact
Name: hui liu
Organization: liuhui
Mailing Address: jinggangshan road 103,,, ji an shi jiang xi 343000 CN
Phone: +86.7968345588
Ext:
Fax: +86.7968345588
Fax Ext:
Email:285997125@qq.com

Tech Contact
Name: hui liu
Organization: liuhui
Mailing Address: jinggangshan road 103,,, ji an shi jiang xi 343000 CN
Phone: +86.7968345588
Ext:
Fax: +86.7968345588
Fax Ext:
Email:285997125@qq.com

Ça n'a évidemment rien à voir avec UPS, ni même avec une branche chinoise d'UPS.

Et pour Paypal ?

Dans ce cas ci, la réponse en plus troublante:
https://whois.icann.org/en/lookup?name=paypal-communication.com

Contact Information

Registrant Contact
Name: Domain Administrator
Organization: PayPal Inc.
Mailing Address: 2211 North First Street,, San Jose CA 95131 US
Phone: +1.8882211161
Ext:
Fax: +1.4025375774
Fax Ext:
Email:hostmaster@paypal.com

Admin Contact
Name: Domain Administrator
Organization: PayPal Inc.
Mailing Address: 2211 North First Street,, San Jose CA 95131 US
Phone: +1.8882211161
Ext:
Fax: +1.4025375774
Fax Ext:
Email:hostmaster@paypal.com

Tech Contact
Name: Domain Administrator
Organization: PayPal Inc.
Mailing Address: 2211 North First Street,, San Jose CA 95131 US
Phone: +1.8882211161
Ext:
Fax: +1.4025375774
Fax Ext:
Email:hostmaster@paypal.com

Il s'agit bien de Paypal :-/

Dans les faits, paypal-communication.com est une branche marketing de Paypal; de toutes façons, je n'ai pas à fournir des informations autres que ce que Paypal connait déjà.

Conclusion

Ne jamais cliquer sur les liens inclus dans les courriels. Dans le doute, aller directement sur le site (Paypal, UPS, ...).

Friday, 14 October 2016

A new folk


A new folk reach my studio: an EMU Proteus 2500.

Comprehensive design with many bells and whistles (layering, multi-track sequencer, arpeggiator, 2 FX engines) and a huge user manual - 356 pages. I only scratched the surface so far; the built in patches are weak by nowadays standards, but the filters are still simply ... wow!