Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Miller anotherlab

View GitHub Profile
@anotherlab
anotherlab / MakeValidCall.cs
Last active May 19, 2021
Sample code code to illustrate how to call MakeValid
View MakeValidCall.cs
/*
SQL code for SQL Server from
https://stackoverflow.com/questions/66496778/sql-statement-including-makevalid-crushing-the-server
*/
/*
C# version using SqlGeography instead of SqlGeometry
Requires the Microsoft.SqlServer.Types assembly
Install-Package Microsoft.SqlServer.Types -Version 14.0.1016.290
*/
void MakeValidCall()
@anotherlab
anotherlab / num-lock.ps1
Last active Jul 5, 2020
Windows-only script to set the state of the Num Lock key
View num-lock.ps1
# One parameter, to set the Num Lock state to On or Off, with
# On as the default
Param(
[Parameter(Mandatory=$false)]
[ValidateSet("On", "Off")]
[String[]] $onoff='On'
)
# Get the current state of the Num Lock key
$CurrentState = [console]::NumberLock
@anotherlab
anotherlab / get-static-console.ps1
Created Jul 4, 2020
Get a list of static members from the system.console class
View get-static-console.ps1
[system.console] | Get-Member -Static -MemberType property | Format-Table name
@anotherlab
anotherlab / adb-32.png
Last active May 23, 2020
Quick little PowerShell script to add the ADB tools to the path
@anotherlab
anotherlab / SysProp.cs
Created Feb 8, 2019
Xamarin C# code to access system properties via Android's hidden SystemProperties class
View SysProp.cs
using System;
namespace Os.Properties
{
// Get access to the hidden SDK class SystemProperties. The SystemProperties
// class provides access to the System Properties store. This store contains
// a list of key-value pairs
// See https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/SystemProperties.java
public static class SysProp
{
@anotherlab
anotherlab / program.cs
Created Apr 6, 2018
Creating a video capture filter with DirectShow
View program.cs
if (new FilterGraph() is IFilterGraph2 graphBuilder)
{
// Create a video capture filter for the device
graphBuilder.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out IBaseFilter capFilter);
// Cast that filter to IAMCameraControl from the DirectShowLib
IAMCameraControl _camera = capFilter as IAMCameraControl;
// Get the current focus settings from the webcam
_camera.Get(CameraControlProperty.Focus, out int v, out CameraControlFlags f);
@anotherlab
anotherlab / program.cs
Created Apr 6, 2018
Using the list of attached webcams
View program.cs
// Get the list of connected video cameras
DsDevice[] devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
// Filter that list down to the one with hyper-aggressive focus
var dev = devs.Where(d => d.Name.Equals("Microsoft® LifeCam HD-5000")).FirstOrDefault();
@anotherlab
anotherlab / Create Android Icons.jsx
Created Nov 13, 2014
Photoshop script to resize 1024x1024 png into Android icons
View Create Android Icons.jsx
// Photoshop Script to Create Android Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@anotherlab
anotherlab / SmokeOnTheWater.c
Last active May 19, 2017
The opening notes of "Smoke On The Water"
View SmokeOnTheWater.c
void Smoke()
{
int v = 50;
int duration = 500;
Beep(v, 2940, duration, 10);
Beep(v, 3490, duration, 10);
Beep(v, 3920, duration * 1.5, 150);
Beep(v, 2940, duration, 10);
@anotherlab
anotherlab / FinalCountDown.c
Last active May 19, 2017
C code to play the opening notes of "The Final Countdown" on an Elatec TWN4 RFID reader
View FinalCountDown.c
void FinalCountDown(void)
{
int v = 100;
int duration = 125;
Beep(v, CS5, duration, 10);
Beep(v, B4, duration, 10);
Beep(v, CS5, duration*4, 10);
Beep(v, FS3, duration*5, duration*5);
Beep(v, D5, duration, 10);