Skip to content

Instantly share code, notes, and snippets.

@camous
camous / glidePicsOffloading.gs
Last active November 16, 2021 08:06
Offload glideapps picture
function glidePicsOffloading() {
var range = "G:I";
var publicDriveFolderId = "__google drive folder id___";
var ss = SpreadsheetApp.getActiveSpreadsheet();
// folder where pictures are located
var picsfolder = DriveApp.getFolderById(publicDriveFolderId);
@camous
camous / routing.cs
Created March 21, 2020 19:08
unittest_routing
[TestMethod]
public void TestMethod1()
{
var servicebus = new NameSpace();
var subscription1 = new Subscription { Name = "subscription1", Rules = new List<Rule> { new Rule { Filter = "flag='1'" } } };
var subscription2 = new Subscription { Name = "subscription2", Rules = new List<Rule> { new Rule { Filter = "flag='2'" } } };
servicebus.Topics.Add(new Topic { Name = "topic", Subscriptions = new List<Subscription> { subscription1, subscription2 } });
/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
* See LICENSE in the project root for license information.
*/
const request = require('superagent');
/**
* Generates a GET request the user endpoint.
* @param {string} accessToken The access token to send with the request.
@camous
camous / json_validate.ps1
Created May 30, 2019 20:42
devops json schema powershell core validation
$schema = Get-Content $Env:schema | Out-String
$err = "";
Get-ChildItem -Filter "*.json" | Where-Object { ($Env:exclude_json -split ',') -notcontains $_.Name} | ForEach-Object {
# first test only json parsing to not mixup error
$json = Get-Content $_ | Out-String -ErrorAction:SilentlyContinue
if(($json | Test-Json -ErrorAction:SilentlyContinue) -eq $true){
# if json parsing is fine, let's check schema
@camous
camous / issue.json
Last active March 2, 2019 20:17
ACME redmine to devops acmemapper definition
{
"issue": [
{
"redmine": "Subject",
"vsts": "/fields/System.Title"
},
{
"redmine": "Author",
"vsts": {
"property": "/fields/System.CreatedBy",
@camous
camous / alterTableDependencyTrigger.cs
Last active May 10, 2017 12:15
alter existing stored procedure produced by TableDependency for supporting "replay"
class Program
{
static void Main(string[] args)
{
using (var con = new SqlConnection(Properties.Settings.Default.ConnectionString))
{
con.Open();
var serverConnection = new ServerConnection(con);
var server = new Server(serverConnection);
@camous
camous / infiniteStreamConsole.js
Last active April 5, 2017 20:54
create infinite console for azure stream with limited memory leaks
var count = 0;
var consoleMaxLines = 0;
function writeLog(text){
var div = document.getElementById("result");
var datetime = moment.utc(text,'YYYY-MM-DDTHH:mm:ss');
if(datetime.isValid()){
text = text.replace(datetime.format('YYYY-MM-DDTHH:mm:ss'),datetime.local().format('HH:mm:ss'));
}
@camous
camous / streamAzureLogStream.js
Last active June 1, 2018 08:12
redirect azure log stream to another web service endpoint
var request = require('request');
var http = require('http');
var express = require('express');
var os = require("os");
var streamoptions = {
url: 'https://xxxxxxx.scm.azurewebsites.net/api/logstream',
headers: {
'Authorization': 'Basic xxxxxxxxxxxxxxxxx'
}
public class Program
{
static JobHost host = null;
static void Main(string[] args)
{
var cancellationToken = new WebJobsShutdownWatcher().Token;
cancellationToken.Register(() =>
{
ShutdownGraceFully();
host.Stop();
@camous
camous / Kill-AzureRmJobs.ps1
Created March 14, 2017 20:27
Lists & kills webjob with based on command name
param(
[string] $AppServiceName = $ENV:AZURE_APPNAME,
[string] $CommandLine = $ENV:AZURE_WEBJOBCOMMANDLINE,
[string] $Headers = $ENV:AZURE_SCM_HEADERS
)
Try
{
Write-Warning "Killing processes $CommandLine in $AppServiceName"
$HeadersHash = ConvertFrom-StringData -StringData $Headers