Skip to content

Instantly share code, notes, and snippets.

select
zip
, cos(radians(latitude)) * cos(radians(longitude)) xaxis
, cos(radians(latitude)) * sin(radians(longitude)) yaxis
, sin(radians(latitude)) zaxis
from zip_axis
/* credit https://stackoverflow.com/a/2233208/812377 */
@wvpv
wvpv / CNX18-RASA-contact-delete.js
Last active January 18, 2023 14:10
CNX18-RASA-contact-delete
<script type="javascript" runat="server">
Platform.Load("core","1.1.5");
var DE = "Contacts_To_Delete";
var logDE = "Contacts_To_Delete_Log";
var log = DataExtension.Init(logDE);
var url = 'https://auth.exacttargetapis.com/v1/requestToken';
var contentType = 'application/json';
# Aliases
alias c="clear"
alias ll="ls -lah"
alias lz="ls -laZ" # include (selinux) security context in listing
alias cl="c && ll"
alias ..="cd .."
# Empty contents of files
empty() {
for arg in "$@"
@wvpv
wvpv / sfmc-asc-xml.html
Last active March 3, 2020 17:30
Parse ASC XML Payload
<html>
<head>
<style>
body, a, input {font-family:sans-serif;}
</style>
</head>
<body style="font-family:sans-serif">
%%=now()=%%
<h1>XML Parse with AMPScript</h1>
@katydorjee
katydorjee / AMPscript and Server-Side JavaScript variable together.html
Created May 6, 2017 08:46
AMPscript and Server-Side JavaScript variable together
%%[
VAR @ProductName
SET @ProductName = "Mobile phone"
]%%
<script runat=server>
Platform.Load("Core","1");
//Get the Variable from AMPscript
@wvpv
wvpv / sfmc-number-suffixes.html
Last active September 19, 2018 21:48
Number Suffixes in AMPScript
%%[
var @day, @suffix
for @day = 1 to 31 do
/* set @day = Format(Now(),"dd") */
/* adapted from http://stackoverflow.com/a/13627586/812377 */
if mod(@day,10) == 1 and mod(@day,100) != 11 then
@wvpv
wvpv / sfmc-lowest-of-three-numbers.html
Created November 11, 2016 14:41
Find the lowest of 3 numbers in AMPScript
%%[
var @num1, @num2, @num3, @lowestNum
/* force strings to be numbers */
set @num1 = add('105.54',0)
set @num2 = add('88.73',0)
set @num3 = add('106.32',0)
/* find lowest with method outlined here: http://stackoverflow.com/a/9424226/812377 */
set @lowestNum = iif(@num1 < iif(@num2 < @num3, @num2, @num3), @num1, iif(@num2 < @num3, @num2, @num3))
@wvpv
wvpv / SFMC-SSJS-delete-rows-from-DE.js
Created March 21, 2016 14:44
SFMC SSJS Delete Rows from a Data Extension
<script runat="server">
Platform.Load("core", "1.1.1");
function pruneRows () {
var DERowKeys = DataExtension.Init("DEofRowKeys");
var DERowKeyRows = DERowKeys.Rows.Lookup(["ProcessedFlag"], [0], 50, "RowDate");
var returnString = "";
@wvpv
wvpv / sfmc-sql-enterprise-attributes.sql
Last active June 15, 2019 19:00
SFMC SQL select profile attributes values from the EnterpriseAtrributes data view
select
a.customerID
, s.emailAddress
from EnterpriseAttributes a
inner join _Subscribers s on (s.subscriberID = a.subscriberID)
@wvpv
wvpv / sfmc-ampscript-preference-center-test.html
Created December 15, 2015 17:13
SFMC AMPScript preference center test email
<html>
<body style="font-family:sans-serif">
<a href="%%profile_center_url%%">Base - Profile/Preference Center</a>
<br/><a href="%%subscription_center_url%%">Base - Subscription Center</a>
<br/><a href="%%unsub_center_url%%">Base - One-Click Unsubscribe</a>
<br/><a href='%%=MicrositeURL(1111,"subscriberMID", "4444")=%%'>Custom Profile/Preference Center</a>
<br/><a href='%%=MicrositeURL(2222,"subscriberMID", "4444")=%%'>Custom Subscription Center</a>
<br/><a href='%%=MicrositeURL(3333,"subscriberMID", "4444")=%%'>One-Click Unsubscribe</a>
<p>This email was sent by:
<b>%%Member_Busname%%</b>