Skip to content

Instantly share code, notes, and snippets.


Itay Shakury itaysk

View GitHub Profile
itaysk / Download-GitHubRepos.ps1
Last active Aug 29, 2015
Download all repositories for a GitHub organization
View Download-GitHubRepos.ps1
Function Download-GitHubRepos ([string][parameter(mandatory=$true)] $orgid, [string]$saveLocation)
if (-not ([string]::IsNullOrEmpty($saveLocation)))
if (-not (Test-Path $saveLocation -PathType Container))
Throw "saveLocation is invalid"
if (-not ($saveLocation.EndsWith('\')) -or ($saveLocation.EndsWith('/')))
itaysk / LB_ARM.ps1
Last active Aug 29, 2015
Azure - Configure Load Balancer for existing VMs (ARM)
View LB_ARM.ps1
#public ip for the load balancer
$lbpip = New-AzurePublicIpAddress -Name "ironlbpip" -ResourceGroupName "iron" -Location "West Europe" –AllocationMethod Dynamic
#configure the public ip as the fronend ip for the load balancer (access endpoint from the internet)
$lbfe = New-AzureLoadBalancerFrontendIpConfig -Name "LB-Frontend" -PublicIpAddress $lbpip
#create an address pool for load balanced servers (later we add addresses to that pool)
$lbbepool= New-AzureLoadBalancerBackendAddressPoolConfig -Name "LB-backend"
#create a load balancing policy: balance all http traffic
$lbrule = New-AzureLoadBalancerRuleConfig -Name "HTTP" -FrontendIpConfiguration $lbfe -BackendAddressPool $lbbepool -Protocol Tcp -FrontendPort 80 -BackendPort 80
#Here we actually create the load balancer resource with all the settings previously defined
$lb = New-AzureLoadBalancer -ResourceGroupName "iron" -Name "ironlb" -Location "West Europe" -FrontendIpConfiguration $lbfe -LoadBalancingRule $lbrule -BackendAddressPool $lbbepool
itaysk / Show_IP.js
Created Aug 3, 2015
Web App that shows the IP address of the server
View Show_IP.js
var http = require('http');
var os = require('os');
var msg = "";
var ifaces = os.networkInterfaces();
Object.keys(ifaces).forEach(function (ifname) {
ifaces[ifname].forEach(function (iface) {
if ('IPv4' !== || iface.internal !== false) {
// skip over internal (i.e. and non-ipv4 addresses
itaysk / Test_LB.js
Created Aug 3, 2015
Test load balancer
View Test_LB.js
var request = require('request');
var a=0 ,b = 0, c=0;
var count=100;
for (var i = 0; i < count; i++) {
request('', function (error, response, body) {
if (!error && response.statusCode == 200) {
if (body == "\n") {
else if (body == "\n") {
itaysk / AzureWebApp-AddVirtuallApplication.ps1
Created Apr 10, 2016
Add a Virtual Application to Azure Web App via PowerShell
View AzureWebApp-AddVirtuallApplication.ps1
$webAppProperties = (Get-AzureRmResource -ResourceGroupName $name -ResourceType Microsoft.Web/sites/config -ResourceName "$(WebAppName)/web" -ApiVersion 2015-08-01).Properties
$webAppProperties.VirtualApplications += [pscustomobject]@{VirtualPath="/$($VirtualPath)"; PhysicalPath="$PhisicalPath"; PreloadEnabled="False"; VirtualDirectories=$null}
#VirtualPath = a the URL path to create. PhisicalPath = a folder in the server to map to, relative to "Home" directory (to create an app parallel to wwwroot, physicalPath should be like "site\newVA")
Set-AzureRmResource -ResourceGroupName $RGname -ResourceType Microsoft.Web/sites/config -ResourceName "$(WebAppName)/web" -ApiVersion 2015-08-01 -Properties $webAppProperties -Force
itaysk / multi_request_retry.js
Last active Aug 28, 2016
Submit multiple http promised requests with retry
View multi_request_retry.js
//demonstrates how to submit multiple http requests, while making sure each is resilient to transient errors using retries
var Promise = require('bluebird');
var rp = require('request-promise');
var retry = require('bluebird-retry');
var createPromise = function(i) {
return retry(function () {
return rp('http://localhost:8000?q='+i).promise();
}, {
import os
import azure.batch.batch_service_client as batch
import azure.batch.batch_auth as batchauth
import azure.batch.models as batchmodels
#--------------this is the part you edit-------------#
batch_account_name = "<your batch account name here>"
batch_account_url = "<your batch account url here>"
itaysk / index.js
Created Jan 19, 2017
Securing Single Page Applications with Azure AD
View index.js
var aadTenant = "",
spaClientId = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", //AAD app client id for this app
serviceClientId = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", //AAD app client id for the service API app
var serviceUrl = "http://localhost:8081/api/doSomething"; // the service API endpoint
var authContext = new AuthenticationContext({
instance: '',
tenant: aadTenant,
clientId: spaClientId,
postLogoutRedirectUri: window.location.origin,
itaysk /
Last active Apr 9, 2018
Get latest (highest) version of a Docker Hub image
curl -L --fail "${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=1000" | \
jq '.results | .[] | .name' -r | \
sed 's/latest//' | \
sort --version-sort | \
tail -n 1
itaysk / legacy-query-oms
Created Nov 10, 2018
Determine who created resources in Azure using Log Analytics
View legacy-query-oms
(ResourceGroup=<ResourceGroupName>) (Resource=<ResourceName>) (ActivityStatus=Succeeded)
| Sort TimeGenerated asc
| Top 1
| Select Caller
You can’t perform that action at this time.