Skip to content

Instantly share code, notes, and snippets.

View fsans's full-sized avatar

Francesc Sans fsans

  • Indie developer
  • Barcelona (Spain)
  • 14:24 (UTC +02:00)
  • X @fsans
View GitHub Profile
@fsans
fsans / AppleScript MailRule to send a WebHook.md
Last active February 28, 2024 10:45
AppleScript for sending a webhook with JSon payload from a mail rule action

WebHook mail action AppleScript

This script takes the body and relevant data from any email and sends a webhook using CURL to a given http destination, with the payload as JSon.

Use it as the action of an email rule, saving it in the scripts com.apple.mail folder:

/Volumes/HD/Library/Application Scripts/com.apple.mail

Modify according to your webhook's destination url on the curlCommand parameter definition.

@fsans
fsans / FMCF isValidEmail(email).md
Last active December 13, 2023 18:10
Validates email address according to RFC 5322, not enforcing domain and TLD length limitations imposed by SMTP

isValidEmail(email)

Let(
[
	_str = lower(email);
	_regex = "\A[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z"

];
	email = BE_RegularExpression ( _str ; _regex )
@fsans
fsans / Local FMJDBC driver maven repository.md
Last active December 13, 2023 18:38
Make yout own Maven repositories for FileMaker JDBC Drivers

Create local maven repositories for FileMaker JDBC Drivers

Simple method to create your own (local) maven repositories for FileMaker JDBC Drivers using the distributed jar files.

Get a copy of the FileMaker JDBC Driver, fmjdbc.jar, from the FileMaker Server installer package (Extras/xDBC folder), or from public distributiuons here:

https://support.claris.com/s/answerview?language=en_US&anum=12921

Generate repo and install the JAR into your local Maven repository

@fsans
fsans / FMCF SQL92_FM Date-Time.md
Last active October 6, 2022 16:40
Format FileMaker Date or Time to SQL92 syntax

SQL92Date(fmdate)

Let(
[
    _year = Right( "0000" & Year( fmdate ); 4 );
    _month = Right( "00" & Month( fmdate ); 2);
 _day = Right( "00" & Day( fmdate ); 2)
@fsans
fsans / FMCF ISO8601_time_functions.md
Last active October 6, 2022 16:30
Convert between ISO8601 and FileMaker Time formats

ISO8601GetTime(isoDate)

Let ( 
  [
	_input_date = Filter( GetValue( Split( isoDate; "T" ); 1 ); "0123456789");
	_input_time = Filter( GetValue ( Split ( GetValue( Split( GetValue( Split( isoDate; "T" ); 2 ) ; "+" ); 1) ; "-" ) ; 1 ); "0123456789.");
	_hour = Left(_input_time;2);
	_minute = Middle ( _input_time ; 3 ; 2 );
	_seccond = Middle ( _input_time ; 5 ; 99 )
@fsans
fsans / FMCF ISO8601_date_functions.md
Last active October 6, 2022 16:34
Convert between ISO8601 and FileMaker Date formats

ISO8601 - FM data and time conversions

ISO8601GetDate( isoDate )

Let ( 
  [
	_input_date = Filter( GetValue( Split( isoDate; "T" ); 1 ); "0123456789");
	_year = Left(_input_date;4);
	_month = Middle ( _input_date ; 5 ; 2 );
	_day = Middle ( _input_date ; 7 ; 2 )
@fsans
fsans / FileMaker_ElasticSearch.md
Last active May 19, 2023 17:51
Integrate FileMaker with ELK stack using JDBC

Add logstash connection to FileMaker

Sync any FileMaker Table to ElasticSearch using Logstash with a JDBC pipeline. Make sure all fields are ISO compliant (keep naming in legacy SQL scope).

Create a jdbc simple pipeline...

input {
	jdbc {
@fsans
fsans / Kickoff all users.md
Last active December 13, 2023 18:30
Disconnect all users from FileMaker Server shell script

Disconnect all users from FileMaker Server.

Save this shell script in /Library/FileMaker Server/Data/Scripts.

Execute as system script in any schedule when you need to free up the service for any task...

#!/bin/sh

# to be kind, send a message to warn connected users...
@fsans
fsans / FMCF UnixTime.md
Last active October 6, 2022 16:47
Returns the seconds since 00:00:00 UTC

UnixTime( )

Returns the seconds since 00:00:00 UTC

Floor( GetAsNumber ( Get ( CurrentTimeUTCMilliseconds ) ) / 1000 ) - GetAsNumber ( Timestamp ( "01/01/1970" ; "00:00:00" ) )
@fsans
fsans / FMCF SQL92 Timestamp.md
Last active December 13, 2023 18:36
Format FileMaker Timestamp to SQL92 syntax

SQL92Timestamp(fmtimestamp)

Let (
[ 
	_error = ""; 
	_dateOrder = JSONGetElement( Get(FileLocaleElements); "Date.DateOrderName");
	_elements	= Split( fmtimestamp; " ");