Skip to content

Instantly share code, notes, and snippets.

View Misiu's full-sized avatar

Tomasz Misiu

  • 21:55 (UTC +01:00)
View GitHub Profile
@Misiu
Misiu / scan_for_i2c_devices
Created June 30, 2020 08:31 — forked from kungpfui/scan_for_i2c_devices
Scan for I2C devices with smbus2 library (like i2cdetect)
#!/usr/bin/env python3
from smbus2 import SMBus
def scan(force=False):
devices = []
for addr in range(0x03, 0x77 + 1):
read = SMBus.read_byte, (addr,), {'force':force}
write = SMBus.write_byte, (addr, 0), {'force':force}
@Misiu
Misiu / ZipNugetPackages.ps1
Created January 7, 2019 10:23
Nuspec & Nupkg versioning
Param(
[Parameter(mandatory=$true)]
[string]$packagesDirectory
)
$compressDirectory =
{
param($directoryPath, $destinationPath)
Compress-Archive -path "$directoryPath\*" -DestinationPath $destinationPath -Force
}
@Misiu
Misiu / ApplyVersionToAssemblies.ps1
Created January 7, 2019 10:23
Nuspec & Nupkg versioning
##-----------------------------------------------------------------------
## <copyright file="ApplyVersionToAssemblies.ps1">(c) Microsoft Corporation.
## This source is subject to the Microsoft Permissive License.
## See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
## All other rights reserved.</copyright>
##-----------------------------------------------------------------------
# Look for a 0.0.0.0 pattern in the build number.
# If found use it to version the assemblies.
#
# For example, if the 'Build number format' build process parameter
@Misiu
Misiu / UnzipNugetPackages.ps1
Created January 7, 2019 10:23
Nuspec & Nupkg versioning
Param(
[Parameter(mandatory=$true)]
[string]$packagesDirectory
)
$expandZipFile =
{
param($zipFile, $zipDestinationPath)
Expand-Archive -path "$zipFile" -DestinationPath $zipDestinationPath -Force
}
@Misiu
Misiu / Set-PackageQuality.ps1
Created January 3, 2019 08:42
Set-PackageQuality.ps1
param
(
[ValidateSet("nuget","npm")][string] $feedType = "nuget",
[string] $feedName="",
[string] $packageId="",
[string] $packageVersion=[regex]::matches($Env:BUILD_BUILDNUMBER, “\d+\.\d+\.\d+\.\d+”),
[string] $packageQuality="",
[switch] $pester
)
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ArduinoOTA.h>
#include <FS.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "SPI.h"
#include "SD.h"
@Misiu
Misiu / FooEnvironmentBuilder.cs
Created May 22, 2017 06:29 — forked from zbynourcz/FooEnvironmentBuilder.cs
Topshelf custom environment builder
class FooEnvironmentBuilder : EnvironmentBuilder
{
readonly HostConfigurator _configurator;
WindowsHostEnvironment _windowHostEnvironment;
public FooEnvironmentBuilder(HostConfigurator configurator)
{
_configurator = configurator;
_windowHostEnvironment = new WindowsHostEnvironment(_configurator);
}
@Misiu
Misiu / CustomTextMessageBindingElement.cs
Created March 24, 2017 13:37
CustomTextMessageEncoder V4
using System;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.Xml;
namespace DokZastrzezoneV4
{
public class CustomTextMessageBindingElement : MessageEncodingBindingElement, IWsdlExportExtension
{
private MessageVersion _msgVersion;
using System;
using System.ServiceModel.Channels;
using System.Xml;
namespace DokZastrzezoneV3
{
public class CustomTextMessageBindingElement : MessageEncodingBindingElement
{
private MessageVersion _msgVersion;
private string _mediaType;
@Misiu
Misiu / MyRfc6238AuthenticationService.cs
Last active November 10, 2022 16:16
Custom implementation of Microsoft's Rfc6238AuthenticationService class from ASP.NET Identity 2.2.1 https://aspnetidentity.codeplex.com/SourceControl/latest#src/Microsoft.AspNet.Identity.Core/Rfc6238AuthenticationService.cs
internal static class MyRfc6238AuthenticationService
{
private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private static readonly TimeSpan DefaultTimeStep = TimeSpan.FromMinutes(3);
private static readonly Encoding Encoding = new UTF8Encoding(false, true);
private static int ComputeTotp(HashAlgorithm hashAlgorithm, ulong timestepNumber, string modifier)
{
// # of 0's = length of pin
const int mod = 1000000;