Skip to content

Instantly share code, notes, and snippets.

View RedTahr's full-sized avatar

Allister RedTahr

  • New Zealand
View GitHub Profile
from gpiozero import LED, MotionSensor, LightSensor
from signal import pause
pir = MotionSensor(21)
ldr = LightSensor(26)
light = LED(25)
def daytime():
pir.when_motion = None
pir.when_no_motion = None
light.off()
def nighttime():
@RedTahr
RedTahr / README.md
Created January 31, 2018 22:29 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@RedTahr
RedTahr / mergeFromDevToCurrentBranch.ps1
Created January 8, 2018 19:42
powershell script to git merge dev branch with currently checked out branch
$currentBranch = git rev-parse --abbrev-ref HEAD
git checkout dev
git pull
git checkout $currentBranch
git merge dev
@RedTahr
RedTahr / versionincrement.ps1
Last active December 17, 2018 17:31 — forked from bradjolicoeur/gist:e77c508089aea6614af3
Powershell Script to Increment Build Number in AssemblyInfo.cs
#
# This script will increment the build number in a file
# refactored from the AssemblyInfo.cs version incrementing gist for use with AndroidManifest.xml
#
#$assemblyInfoPath = "C:\Data\Temp\AssemblyInfo.cs"
$mani = "C:\Data\Temp\AndroidManifest.xml"
#$contents = Get-Content $assemblyInfoPath # looses file formatting
$contents = [System.IO.File]::ReadAllText($mani)
@RedTahr
RedTahr / CarouselLayout.cs
Created January 6, 2016 20:01
My copy of chrisriesgo / xamarin-forms-carouselview using Montemagno's FrenchPressTimer (see gist > Timer.cs)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
// using System.Timers;
using Xamarin.Forms;
namespace ....Core.Control
{
public class CarouselLayout : ScrollView, IDisposable
@RedTahr
RedTahr / Timer.cs
Created January 6, 2016 19:59
My copy of Montemagnos FrenchPressTimer (for those times when I want a System.Timer in Xamarin.Forms PCL)
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ....Core.Control {
// https://github.com/jamesmontemagno/FrenchPressTimer/blob/master/SimpleTimerPortable/Timer.cs
internal delegate void TimerCallback(object state);
internal sealed class Timer : CancellationTokenSource, IDisposable {
public Timer(TimerCallback callback, object state, int dueTime, int period) {
@RedTahr
RedTahr / AboutPage.xaml
Created July 15, 2015 21:06
Xamarin.Forms DerivedPage.xaml/cs from BasePage, Binding ViewModel in XAML.
<?xml version="1.0" encoding="utf-8" ?>
<derived:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="....AboutPage"
xmlns:local="clr-namespace:...;assembly=..."
xmlns:derived="clr-namespace:....View;assembly=..."
BindingContext="{x:Static local:App.AboutViewModel}"
Title="About">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Label Text="{Binding Detail}"/>
@RedTahr
RedTahr / BasePage.cs
Last active January 27, 2016 19:22
Xamarin.Forms BasePage
namespace ... {
// for supporting this
// public partial class "Derived"Page : "Derived"PageXaml {.... } for a xaml/cs page
// then
// <?xml version="1.0" encoding="utf-8" ?><local:"Derived"tPageXaml xmlns="ht...
// with this bit in the cs file
// public partial class "Derived"PageXaml : BasePageOverrideBackButton<ViewModel."Derived"ViewModel> { }
public class BasePageOverrideBackButton<T> : BasePage<T> where T : ViewModel.BaseViewModel, new() {
public BasePageOverrideBackButton() : base() {
}
@RedTahr
RedTahr / BaseViewModel.cs
Last active January 27, 2016 19:25
Xamarin.Forms BaseViewModel
namespace ... {
public abstract class BaseViewModel : BindableObject { // yeah its overkill, can't recall why my colleague did it this way
private string title = string.Empty;
public string Title {
get { return title; }
set {
if(title != value) {
title = value;
RaisePropertyChanged();
@RedTahr
RedTahr / DisableScPnP.ps1
Last active August 29, 2015 14:23
SmartCard PnP Disable
# Disable Smart Card PnP
# [x86]
# [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\ScPnP]
# "EnableScPnP"=dword:00000000
# [64-bit]
# HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\ScPnP]
# "EnableScPnP"=dword:00000000
# this Wow6432Node entry is a "hardlink" to the above entry, so you create/delete/edit that and the changes are mirrored in Wow6432Node