Skip to content

Instantly share code, notes, and snippets.

View izotope115's full-sized avatar

Gabe Khofri izotope115

View GitHub Profile
%%[
VAR @httppost,@apiid,@apistatusCode,@apiresponse,@apitoken
SET @apiid = '{"client_id": "client_id","client_secret": "client_secret", "grant_type": "client_credentials","account_id": "MID"}' /* Forming up the string for getting the access token */
SET @httppost = HTTPPost2("https://xyz.auth.marketingcloudapis.com/v2/token","application/json",@apiid,true,@apiresponse,@responseRows) /* Making a POST call to get access token */
IF(@httppost == "200") Then /* If status is Sucess */
set @rows = BuildRowsetFromString(@apiresponse,'"') /* Split the rows based on '"' string */
set @rowCount = rowCount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowCount do
var @apitoken
@wvpv
wvpv / sfmc-sql-pushaddress.sql
Created December 10, 2019 14:59
Query to pull PushAddress data
select
_ContactID ContactID
, _DeviceID DeviceID
, _APID APID
, _Status Status
, _Source Source
, _SourceObjectId SourceObjectId
, _Platform Platform
, _PlatformVersion PlatformVersion
, _Alias Alias
<script language=javascript runat=server>
Platform.Load("core", "1")
var b1 = DataExtension.Init("Test_AddSubscribers");
var data = b1.Rows.Lookup(["IsSubscriber"], ["False"]);
if(data){
for (var i = 0; i < data.length; i++){
var status;
var EmailAddress = data[i]["EmailAddress"];
if(EmailAddress && EmailAddress != ""){
var results = Subscriber.Retrieve({
@wvpv
wvpv / sfmc-ampscript-one-click-unsubscribe.html
Last active October 6, 2023 03:42
One-Click Unsubscribe AMPscript
%%[
var @debug
var @jid
var @listid
var @batchid
var @email
var @skey
var @reason
var @unsubscribeAll
@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';
@kremalicious
kremalicious / sshkey.sh
Created September 27, 2017 18:40
Add local public ssh key to server
cat ~/.ssh/id_rsa.pub | ssh user@hostname -i ~/.ssh/key.key 'cat >> .ssh/authorized_keys'
@psapir
psapir / Writing a REST Service with Cloud Pages - GET Method Secured
Created August 3, 2017 15:20
Writing a REST Service with Cloud Pages - GET Method Secured
if not empty (@token) then
set @rows = LookupRows("Rest api authorization","AccessToken",@token)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
If @action=="get" and not empty (@entrycode) then
set @rows = LookupRows("Register","EntryCode",@entrycode)
set @rowCount = rowcount(@rows)
If @rowCount==0 then
output(v(@JsonNotFound))
@kremalicious
kremalicious / openvpn-server.sh
Last active August 20, 2019 15:38
Hardened OpenVPN server on Ubuntu including client configuration script
#
# Hardened OpenVPN server on Ubuntu 16.04
# repeatable config generation script at end
#
# TOC
# ----
# 1. SERVER
# 2. NETWORKING
# 3. CLIENTS
# 3.1. REPEAT FOR EACH CLIENT
@kremalicious
kremalicious / tor-hidden-service-host.sh
Last active October 31, 2023 20:48
Install and run Tor hidden service on pretty much anything
##
# for Ubuntu 16.04 Xenial Xerus
##
######################################
# INITIAL SERVER SETUP & HARDENING
######################################
# most VPS providers give you root user from the start
ssh root@1.2.3.4
@kremalicious
kremalicious / create-gpg-key.sh
Created May 20, 2017 22:19
Create & publish new GPG key incl. revocation certs
# Generate key pair and revocation certificate.
gpg --gen-key
gpg --output revoke.asc --gen-revoke <key-id>
# Export ASCII copy of the public key
gpg --export --armor <key-id> > pubkey.asc
# Publish the public key
gpg --send-keys <key-id>