Skip to content

Instantly share code, notes, and snippets.

View pveller's full-sized avatar

Pavel Veller pveller

View GitHub Profile
@pveller
pveller / pubsub.js
Last active August 23, 2022 07:41
AWS Amplify PubSub with IoT and Cognito
/*
In order to subscribe to the AWS IoT topic over WS (over MQQT),
you have to make sure that your Cognito identity has a proper IoT policy attached to it.
More details and the message from the official AWS support:
https://github.com/aws/aws-amplify/issues/749
This code shows how you can dynamically attach a policy to the authenticated identity.
Make sure that your Authenticated IAM in the Cognito User Pool has proper IoT permissions.
@pveller
pveller / transcript.js
Last active April 11, 2017 16:34
Conversation Transcript with Bot Framework
// Read more on http://www.pveller.com/smarter-conversations-part-4-transcript/
const transcript = function (session, direction, message, next) {
session.privateConversationData.transcript = session.privateConversationData.transcript || [];
session.privateConversationData.transcript.push({
direction,
message,
timestamp: new Date().toUTCString()
});
$page = Get-Item -Path '/sitecore/content/Habitat/Home/Modules/Feature/Accounts'
$links = [Sitecore.Globals]::LinkDatabase
$processed = New-Object System.Collections.ArrayList
# template names of items that will be linked from the presentation field that are not datasources
$skip = @('Device','Layout','View rendering', 'Controller rendering', 'Test Definition', 'Multivariate Test Variable')
# shared and final layout
$layouts = @('{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}', '{04BF00DB-F5FB-41F7-8AB7-22408372A981}')
@pveller
pveller / sitecore-images-classifier.ps1
Created September 7, 2016 02:36
Using Microsoft Computer Vision API to automatically tag and describe Sitecore Habitat images (http://www.pveller.com/image-tagging-automation-with-computer-vision)
$vision = 'https://api.projectoxford.ai/vision/v1.0/analyze'
$features = 'Categories,Tags,Description,Color'
$images = Get-ChildItem -Path '/sitecore/media library/Habitat/Images/Square'
$result = @()
foreach ($image in $images)
{
# Reading the binary of the image so that we could send it to the Computer Vision API
$media_url = New-Object 'Sitecore.Resources.Media.MediaUri' $image
@pveller
pveller / import.ps1
Last active May 17, 2019 09:05
Sitecore Content Import with Powershell
# http://jockstothecore.com/content-import-with-powershell-treasure-hunt
function NormalizeName($name)
{
# replace all special symbols with single spaces
$name = $name -replace "[^a-zA-Z0-9]", " " -replace "\s+", ""
return $name.Trim()
}
@pveller
pveller / CustomJettyLauncher.java
Created June 1, 2012 19:47
GWT Jetty Launcher to work with JNDI in the hosted mode (dev)
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software