Skip to content

Instantly share code, notes, and snippets.

@kraigspear
kraigspear / NEHotspotConfigurationManager.swift
Created October 11, 2017 09:19
Connect to a WIFI hotspot programmatically in iOS 11
//
// ViewController.swift
// NetworkTest
//
// Created by Kraig Spear on 10/10/17.
// Copyright © 2017 spearware. All rights reserved.
//
import UIKit
import NetworkExtension
--framework:/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework
@kraigspear
kraigspear / WifiConnect.cs
Last active March 28, 2024 14:03
Connect to WIFI via code in Xamarin Android
using System;
using System.Collections.Generic;
using System.Linq;
using Android.App;
using Android.Content;
using Android.Net.Wifi;
using Android.Widget;
using Android.OS;
using Android.Runtime;
@kraigspear
kraigspear / Logger.swift
Created May 18, 2018 07:52
Logger Using CosmosDB
//
// Logger.swift
// SpearSwiftLib
//
// Created by Kraig Spear on 4/22/18.
// Copyright © 2018 spearware. All rights reserved.
//
import Foundation
@kraigspear
kraigspear / Logger.cs
Last active May 18, 2018 08:06
Azure Logging to Cosmos DB
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace Logger
@kraigspear
kraigspear / FetchLogs.cs
Last active May 18, 2018 08:12
Fetching Logs from CosmosDB
public static class HttpTrigger
{
[FunctionName("HttpTrigger")]
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)]HttpRequest req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
string maxCountStr = req.GetQueryParameterDictionary().FirstOrDefault(q => string.Compare(q.Key, "max", true) == 0).Value;
int maxCount = 200;
@kraigspear
kraigspear / MacApp.swift
Created May 18, 2018 08:18
Mac App to show logs
//
// LogFetcher.swift
// LogQuery
//
// Created by Kraig Spear on 5/13/18.
// Copyright © 2018 spearware. All rights reserved.
//
import Foundation
import SpearSwiftLibmacOS
//
// URLProtocolMock.swift
// WeatherKitTests
//
// Created by Kraig Spear on 12/15/19.
// Copyright © 2019 spearware. All rights reserved.
//
import Foundation
import XCTest
@kraigspear
kraigspear / PublishedProtocol.swift
Last active June 19, 2020 10:12
Adding a publisher to a protocol
protocol VehicleDataLoadable {
var vehiclePublisher: Published<Vehicle?>.Publisher { get }
}
final class VehicleDataLoader: VehicleDataLoadable {
@Published var vehicle: Vehicle?
var vehiclePublisher: Published<Vehicle?>.Publisher { $vehicle }
}
@kraigspear
kraigspear / QRCodeGeneration.swift
Last active March 17, 2021 05:25
Generate A QR Code
//
// QRCodeGeneration.swift
// TempCheck
//
// Created by Kraig Spear on 6/12/20.
//
import CoreImage.CIFilterBuiltins
import UIKit