Skip to content

Instantly share code, notes, and snippets.

function Dispatcher() {
this._lastID = 0;
this._callbacks = {};
}
Dispatcher.prototype.register = function(callback) {
var id = 'CID_' + this._lastID++;
this._callbacks[id] = callback;
return id;
};
@Azadehkhojandi
Azadehkhojandi / markup.html
Last active October 19, 2016 23:45
How to have responsive hamburger menu and brand logo with boot strap v4 alpha
<nav class="navbar navbar-light header-background p-x-0" id="nav2">
<button class="navbar-toggler hidden-lg-up pull-xs-right" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar2" aria-controls="exCollapsingNavbar2" aria-expanded="false" aria-label="Toggle navigation">
&#9776;
</button>
<a class="navbar-brand hidden-md-down p-l-1" href="#">
<img class="img-fluid" alt="" src="/images/Logo.png">
</a>
<a class="navbar-brand hidden-lg-up p-l-1" href="#">
<img width="100" alt="" src="/images/Logo.png">
</a>
@Azadehkhojandi
Azadehkhojandi / gulpfile.js
Last active May 16, 2018 06:18
Gulp webserver boilerplate
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect'); //Runs a local dev server
var open = require('gulp-open'); //Open a URL in a web browser
var config = {
port: 9005,
url: 'http://localhost',
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())
@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);
}
@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 / 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 / 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 / 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 / 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"