Skip to content

Instantly share code, notes, and snippets.

View isaacrlevin's full-sized avatar

Isaac Levin isaacrlevin

View GitHub Profile
@isaacrlevin
isaacrlevin / RedditPoller.cs
Created August 3, 2017 21:50
Polling with Reddit
public static class RedditPoller
{
[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
{
string url = "https://www.reddit.com/r/azure/new/.json";
List<Child> children = new List<Child>();
WebClient client = new WebClient();
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class JWTInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (req.method === 'DELETE' || req.method === 'POST' || req.method === 'PUT') {
let currentUser = JSON.parse(localStorage.getItem('currentUser'));
@isaacrlevin
isaacrlevin / Submit.cs
Last active November 21, 2018 19:56
Azure Function Contact Form
public static class Submit
{
[FunctionName("Submit")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
// Getting Form Data items from Request
var from = req.Form["fromEmail"].ToString();
var fromName = req.Form["fromName"].ToString();
@isaacrlevin
isaacrlevin / Function Code
Created July 30, 2019 17:11
Running CMD with Azure Function
System.Diagnostics.Process process = new System.Diagnostics.Process();
string WorkingDirectoryInfo = @"D:\home\site\wwwroot\";
string ExeLocation = @"D:\home\site\wwwroot\gitWork.cmd";
Process proc = new Process();
ProcessStartInfo info = new ProcessStartInfo();
try
{
info.WorkingDirectory = WorkingDirectoryInfo;
info.FileName = ExeLocation;
using Octokit;
using System;
using System.Threading.Tasks;
using System.Diagnostics;
namespace UpdateGitHub
{
class Program
{
@using Microsoft.AspNetCore.Authentication
@model TrafficViewModel
<div class="demo-section k-content wide">
@(Html.Kendo().Chart(Model.CloneSummary.Clones)
.Name("chart")
.Title("Internet Users in United States")
.Legend(legend => legend.Visible(false))
.Series(series => {
@isaacrlevin
isaacrlevin / Program.cs
Created November 19, 2021 23:18
Azure SDK
var credential = new AzureCliCredential();
ArmClient armClient = new ArmClient(credential);
var subscriptions = armClient.GetSubscriptions();
var sub = subscriptions.Where(a => a.Data.SubscriptionGuid == mySubId).FirstOrDefault();
var creds = new AzureIdentityFluentCredentialAdapter(sub.Data.TenantId, AzureEnvironment.AzureGlobalCloud);
// fails here
var websites = await Azure.Authenticate(creds)
.WithSubscription(sub.Data.DisplayName)
.WebApps.ListByResourceGroupAsync(rgName);
@isaacrlevin
isaacrlevin / LoopbackHttpListener.cs
Last active November 23, 2021 19:48
Sample showing issue with Listener
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
@isaacrlevin
isaacrlevin / .env
Created April 15, 2022 16:01
Elastic 8.2 Docker Compose
STACK_VERSION=8.2.0-8ea0c40f
ELASTIC_PASSWORD=changeme
KIBANA_PASSWORD=changeme
ES_PORT=9200
CLUSTER_NAME=es-cluster
LICENSE=basic
MEM_LIMIT=1073741824
KIBANA_PORT=5601
ENTERPRISE_SEARCH_PORT=3002
ENCRYPTION_KEYS=secret
@isaacrlevin
isaacrlevin / Components-Account-Pages-Manage-Index.razor
Created February 20, 2024 20:37
Blazor Boolean Form Submission
@page "/Account/Manage"
@using System.ComponentModel.DataAnnotations
@using Microsoft.AspNetCore.Identity
@using Scheduler.Data
@inject UserManager<ApplicationUser> UserManager
@inject SignInManager<ApplicationUser> SignInManager
@inject IdentityUserAccessor UserAccessor
@inject IdentityRedirectManager RedirectManager