Skip to content

Instantly share code, notes, and snippets.

View dazfuller's full-sized avatar
🤌
reality.foldLeft

Darren Fuller dazfuller

🤌
reality.foldLeft
View GitHub Profile
@dazfuller
dazfuller / main.ts
Created April 17, 2022 17:48
Some prime number calculations using TypeScript
/* eslint-disable max-len */
import { stdout } from 'process';
/**
* Approximates the nth prime number. This goes deliberately high so that we get a few more prime numbers
* and avoid cutting the sequence early.
* @param n The nth prime number to approximate
* @returns An approximation of the nth prime
*/
function approximateNthPrime(n: number): number {
@dazfuller
dazfuller / .\templates\function-app.bicep
Last active September 10, 2024 19:44
Example template for deploying an Azure Function app with KeyVault references all set in Bicep
/*
** Parameters
*/
@minLength(3)
@maxLength(6)
@description('Prefix to be used by all resources deployed by this template')
param resourcePrefix string = 'demo'
@allowed([
'Standard_LRS'
@dazfuller
dazfuller / Pipfile
Last active October 26, 2024 12:09
Multi-process loading of data into MySQL from Python
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
mysql-connector-python = "*"
@dazfuller
dazfuller / Program.cs
Created December 16, 2019 08:08
Adding multiple tables to a worksheet using EPPlus
using System.IO;
using OfficeOpenXml;
namespace dotnet_excel_demo
{
class Program
{
static void Main(string[] args)
{
using var package = new ExcelPackage();
@dazfuller
dazfuller / azuredeploy.json
Last active October 1, 2021 15:42
Azure Data Lake Gen 2 - ARM template
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "0.0.0.1",
"parameters": {
"resourcePrefix": {
"type": "string",
"minLength": 3,
"maxLength": 10,
"metadata": {
"description": "The prefix to use for resources within the resource group"
@dazfuller
dazfuller / azure_aad_function.py
Last active August 17, 2018 15:29
Calling an Azure Active Directory (AAD) secured Azure Function from Python
import json
import requests
with open('settings.json', 'r') as fp:
settings = json.load(fp)
CLIENT_ID = settings['clientId']
CLIENT_SECRET = settings['clientSecret']
TENANT_ID = settings['tenantId']
APP_ID_URI = settings['appIdUri']
@dazfuller
dazfuller / Program.cs
Last active February 9, 2018 16:31
Reading Parquet from Azure Blob
using System;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Parquet;
namespace ParquetFromAzureBlob
{
public static class Program
{
private const string AccountName = "<account name>";
@dazfuller
dazfuller / License.md
Last active July 2, 2024 12:37
Exporting data from a database to Parquet files in .NET (Core). This demo application targets a SQL Server database but the code could be re-used to target other database solutions.

MIT License

Copyright (c) 2018 Darren Fuller

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@dazfuller
dazfuller / Get-AzureRmVMPrivateIPAddresses.ps1
Created June 14, 2017 11:40
Find the primary private IP address of VMs in Azure
$VMs = Get-AzureRmVM
$Results = @()
ForEach ($VM in $VMs)
{
ForEach ($NicID in $VM.NetworkInterfaceIDs)
{
$Nic = Get-AzureRmResource -ResourceId $NicID | Get-AzureRmNetworkInterface
$Result = New-Object PSObject
$Result | Add-Member -MemberType NoteProperty -Name "ResourceGroupName" -Value $VM.ResourceGroupName
<#
.DESCRIPTION
A runbook which will enable security settings for all database servers and databases in a subscription
.NOTES
AUTHOR: @dazfuller
LASTEDIT: Jan 30, 2016
#>
$connectionName = "AzureRunAsConnection"