Skip to content

Instantly share code, notes, and snippets.

@Azadehkhojandi
Azadehkhojandi / createUiDefinition.json
Last active March 2, 2020 04:21
A sample that creates one storage account and one azure function and it's dependent resources (app insights, storage, ...)
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{}
],
"steps": [
{
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{}
],
"steps": [
{
from platform import python_version
print(python_version())
os.environ['PYTHONPATH']=str(sys.executable)+':/data/home/oneweek/notebooks/models/research:/data/home/oneweek/notebooks/models/research/slim'
print (os.environ['PYTHONPATH'])
! python --version
! echo "PYTHONSTARTUP:" $PYTHONSTARTUP
! echo "PYTHONPATH:" $PYTHONPATH
! echo "PYTHONHOME:" $PYTHONHOME
@Azadehkhojandi
Azadehkhojandi / testgo.sh
Created October 25, 2018 22:37
running go tests and export the results for azure devops
echo "get the go-junit-report package"
go get -u github.com/jstemmer/go-junit-report
echo "run the tests"
go test -v ./tests 2>&1 > go-test-result && exitCode=$? || exitCode=$?
echo "Write the result.xml file"
cat go-test-result | $(GOBIN)/go-junit-report > report.xml
echo "result: $exitCode"
@Azadehkhojandi
Azadehkhojandi / classify.py
Created February 27, 2018 01:25
Using exported custom vision tensor-flow model in python
import sys
import os
import tensorflow as tf
import numpy as np
import scipy
from PIL import Image
from scipy import misc
cwd = os.getcwd()
@Azadehkhojandi
Azadehkhojandi / digitsocr.py
Created November 20, 2017 06:59
K-Nearest Neighbors with the MNIST Dataset
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.image as mp_image
import matplotlib.pyplot as mp_pyplot
mnist = input_data.read_data_sets("minst_data/", one_hot=True)
training_digits, training_lables = mnist.train.next_batch(5000)
test_digits, test_lables = mnist.train.next_batch(10)
@Azadehkhojandi
Azadehkhojandi / FaceApiService.cs
Last active June 14, 2017 02:45
How to call Microsoft cognitive services face api in unity , Imagine you can take snap shot of the user can show different content based on their gender, age or emotion! read more here https://azure.microsoft.com/en-au/services/cognitive-services/face/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Assets.Scripts.Models;
using UnityEngine;
//https://www.packtpub.com/books/content/using-rest-api-unity-part-1-what-rest-and-basic-queries
namespace Assets.Scripts.Services
{
@Azadehkhojandi
Azadehkhojandi / FaceApiService.cs
Created June 14, 2017 02:36
how to call Microsoft cognitive services face api in unity
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Assets.Scripts.Models;
using UnityEngine;
//https://www.packtpub.com/books/content/using-rest-api-unity-part-1-what-rest-and-basic-queries
namespace Assets.Scripts.Services
{
@Azadehkhojandi
Azadehkhojandi / CreateSHA256Signature
Last active December 24, 2023 14:52
Create SHA256 Signature for payment gateway (bendigo bank)
public static string CreateSHA256Signature(string key, string message)
{
// Hex Decode the Secure Secret for use in using the HMACSHA256 hasher
// hex decoding eliminates this source of error as it is independent of the character encoding
// hex decoding is precise in converting to a byte array and is the preferred form for representing binary values as hex strings.
var convertedHash = new byte[key.Length / 2];
for (var i = 0; i < key.Length / 2; i++)
{
convertedHash[i] = (byte)int.Parse(key.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
}
using Sitecore.StringExtensions;
namespace SOPA.Framework.Helpers
{
using Sitecore.Data;
using Sitecore.Resources.Media;
public static class MediaHelper
{
public static string GetImageUrl(string imageSrc, int width, int height, bool allowStretch, bool protectAssetUrl)
{
if (imageSrc.IsNullOrEmpty())