Skip to content

Instantly share code, notes, and snippets.

@ivakhnov
ivakhnov / UploadApiService.cs
Created August 19, 2021 08:39
[UploadApiService]
using Microsoft.WindowsAzure.Storage.Blob;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using PNG.ContentHub.GifConversion.Utils;
using PNG.ContentHub.GifConversion.Helpers;
@ivakhnov
ivakhnov / GlobalProtect.md
Created February 28, 2020 21:31
[How to quit GlobalProtect (mac)] If you've used the globalprotect client for Mac, you may notice that there is no way to exit it, meaning it can continue submitting information about your system to your company in the background, including your current patches, interface information and much much more, even at times you're not connected to the …

We can just unload the launchd script keeping it alive.

Stop spying on me:

launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*

I want to use the VPN again:

launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*

@ivakhnov
ivakhnov / ES _Sorting.json
Last active June 4, 2020 14:21
[AuditRaw by date sorting] Get the auditRawEntry messages for a specific "targetId" sorted chronologically by Date. #sitecorecontenthub #AuditRaw #ElasticSearch
{
"query": {
"bool": {
"must": [
{
"term": {
"targetId": "123456"
}
}
],
@ivakhnov
ivakhnov / dns.aspx
Created February 24, 2020 11:02
[Identify WebApp behind the TrafficManager] Add this file to the site/wwwroot folder on all the distributed Azure WebApps behind a TrafficManager pointed by delivery.xxx.com. Then, target the delivery.xxx.com/dns.aspx in order to identify which of the WebApps you are targeting because of the TM. #AzureWebApp #TrafficManager #Distributed #DNS
<% @ Page Language="C#" %>
<html>
<head>
<title>DNS test</title>
</head>
<body>
<pre>
<%
Response.Write(Request.ServerVariables["HTTP_X_SITE_DEPLOYMENT_ID"]);
@ivakhnov
ivakhnov / ExternalComponentInvokingScript.js
Last active July 1, 2020 15:13
[ExternalComponent invoke Scripting] Whenever you need to invoke an action Script (which you don't need to register in an M.Action entity), you can reuse the following construction. #sitecorecontenthub, #contenthub, #scripting, #externalcomponent #externalcomponentandscripting
var scriptIdentifier = "8m_bVGGMxk-zBdlAMuQVWA"; // No M.Action entity needed, just use the script identifier directly
var jsonData = { AssetId: assetId };
$.rest.post(`/api/scripts/${scriptIdentifier}/execute`, jsonData)
.done(function () {
options.messageBoard.addMessage({
text: "The script was invoked successfully!", level: "success"
});
})
.fail(function (xhr) {
@ivakhnov
ivakhnov / GetImpersonatedClientAsync.csx
Last active February 21, 2020 15:52
[Get Impersonated MClient] Whenever you need to have an impersonated instance for another user of the MClient in the Action Script. #sitecorecontenthub, #contenthub, #actionscript, #scripting, #impersonating
using Stylelabs.M.Sdk;
var id = Context.TriggeringUserId.Value
var client = await GetImpersonatedClientAsync(userId).ConfigureAwait(false);
async Task<IMClient> GetImpersonatedClientAsync(long userId)
{
// Unfortunately for now, there is only one overload of the method which receives the username, not the Id
// of the user you want to impersonate. Hence, we need to load the username
@ivakhnov
ivakhnov / MergeReplaceAsset.csx
Last active February 21, 2020 15:31
#[Asset versioning (Complete ActionScript)] The script receives two asset Ids, then takes the file related through MasterFile relation of one asset and makes this file entity as the new version of the MasterFile of the other asset. Updates the FileHistory of the second asset and entirely deletes the first asset. #sitecorecontenthub #contenthub #…
using Stylelabs.M.Sdk;
using System.Linq;
using System.Threading.Tasks;
// People should not be calling the endpoint of this Script directly.
// It's meant to be "behind" of the automatised raw component.
var destinationAssetIdString = Context.Data["destinationAssetId"]?.ToString();
var sourceAssetIdString = Context.Data["sourceAssetId"]?.ToString();