Skip to content

Instantly share code, notes, and snippets.

@mburumaxwell
mburumaxwell / BlobStorageResult.cs
Last active September 14, 2021 05:12
Serving Azure Blobs using custom ActionResult and IActionResultExecutor
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Represents an <see cref="ActionResult"/> that when executed
/// will write a file from a blob to the response.
@mburumaxwell
mburumaxwell / JsonPatchDocumentExtensions.cs
Last active June 21, 2022 21:50
Immutable properties using JSON Patch in ASP.NET Core
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
public static JsonPatchDocumentExtensions
{
public static void ApplyToSafely<T>(this JsonPatchDocument<T> patchDoc,
@mburumaxwell
mburumaxwell / azure-pipelines.yml
Last active June 6, 2020 07:02
Build and test swift packages in Azure Pipelines
# Build and test swift packages with GitVersion
trigger:
batch: true
branches:
include:
- master
pool:
vmImage: 'macos-latest'
@mburumaxwell
mburumaxwell / NginxWrapper.cs
Created March 27, 2020 16:23
NGINX for Service Fabric
internal sealed class NginxWrapper : StatelessService
{
public NginxWrapper(StatelessServiceContext context) : base(context) { }
protected override async Task RunAsync(CancellationToken cancellationToken)
{
// listen to changes in configuration
Context.CodePackageActivationContext.ConfigurationPackageModifiedEvent += OnConfigurationPackageModified;
ServiceEventSource.Current.ServiceMessage(Context, "Service started. Configuration changes listener registered");
while (true)
{
@mburumaxwell
mburumaxwell / main.c
Last active February 5, 2017 18:15
PCF8563 with NXP Cortex-M3, LPC1343 Keil
#include <LPC13xx.h>
#include <stdbool.h>
#include "i2c.h"
#include <time.h>
#include "pcf8563.h"
tm_t timestamp;
int main(void) {
SystemCoreClockUpdate(); /* Initialize CPU and CMSIS */
@mburumaxwell
mburumaxwell / ActionBarActivityDelegateCompat.java
Created January 4, 2014 11:18
Implementing PreferenceActivity using ActionBarCompat. Add all these files to your project in a package name: android.support.v7.app In your PreferenceActivity extend ActionBarPreferenceActivity If you haven't started using ActionBarCompat and need to implement a PreferenceActivity, I advice you use ActionBarSherlock
package android.support.v7.app;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
@mburumaxwell
mburumaxwell / ApiManager.java
Last active December 31, 2015 19:29
Using date time fields in android(Java) against a C# api
package com.myapphelper.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.List;
import org.apache.http.HttpResponse;
@mburumaxwell
mburumaxwell / MyExtensions.cs
Created June 10, 2013 14:28
Setting the selected menu item in ASP.NET MVC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
namespace MvcApplication1 {
public static class HtmlExtensions {
@mburumaxwell
mburumaxwell / DevicePagerAdapter.java
Last active November 16, 2018 11:58
Using menudrawer(SimonVT), viewpager and TitlePageIndicator
package com.tingle.abeltrac.ui.util;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.tingle.abeltrac.R;
public class DevicePagerAdapter extends FragmentPagerAdapter {
private final Resources resources;