Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

Timothy Macharia tmacharia

:octocat:
Focusing
  • Nairobi, KE
View GitHub Profile
View publish.md

For publishing, open up a new terminal/command prompt and follow the following steps.

  1. Change the directory to the KTDASMS folder

For example, this is what i need to type to access that folder on my local machine, do the same on your machine changing the path shown below to reflect the location of the KTDASMS folder on your machine

cd "C:\Users\tmacharia\Downloads\Notifyr 2.0\Notifyr 2.0\KTDASMS"
@tmacharia
tmacharia / uwp-gradient-stops.cs
Last active Feb 1, 2020
Generate a smooth looking linear color gradient for use in UWP apps that for example scales from transparent to Black
View uwp-gradient-stops.cs
private void Usage()
{
MyGrid.Background = new LinearGradientBrush()
{
GradientStops = GetGradientStops(Colors.Black, 8)
};
}
/// <summary>
/// Generate a smooth <see cref="GradientStopCollection"/> from transparent to the specified target
/// <see cref="Color"/> with the specified <paramref name="numOfStops"/>.
View uwp-clock-backend.cs
using System;
using Windows.Xaml;
namespace uwp.clock.backend
{
public sealed partial class UwpClockPage : Page
{
private readonly DispatcherTimer _timer;
private double PreviousAngle = 0;
public UwpClockPage()
View uwp-clock-one-second-hand.xaml
<Grid Background="#242631" Height="400" Width="400" VerticalAlignment="Center" HorizontalAlignment="Center">
<!-- Clock Ellipse/Frame -->
<Border x:Name="ClockEllipse" CornerRadius="400" Background="#323443"/>
<Canvas HorizontalAlignment="Center" VerticalAlignment="Center">
<Path x:Name="SecHandPath" StrokeThickness="1" Stroke="DeepPink" Data="M 0,40 L 0 -150" RenderTransformOrigin="0,0">
<Path.Resources>
<Storyboard x:Name="SpinSecHandStoryBoard">
<DoubleAnimation x:Name="SpinSecHandAnim" Storyboard.TargetName="SecHandPath" FillBehavior="HoldEnd" AutoReverse="False" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)">
</DoubleAnimation>
@tmacharia
tmacharia / uwp-clock-one-markers.xaml
Last active Nov 24, 2019
Clock frame with 12,3,6,and 9 O'Clock plus the central Markers
View uwp-clock-one-markers.xaml
<Grid Background="#242631" Height="400" Width="400" VerticalAlignment="Center" HorizontalAlignment="Center">
<!-- Clock Ellipse/Frame -->
<Border x:Name="ClockEllipse" CornerRadius="400" Background="#323443"/>
<!-- Central Markers -->
<Border Height="30" Width="30" CornerRadius="70" Background="#242631"/>
<Border Height="12" Width="12" CornerRadius="20" Background="LightGray"/>
<!-- O'Clock Markers -->
<Border Height="10" Width="10" CornerRadius="10" Margin="15" Background="DeepPink" VerticalAlignment="Top" HorizontalAlignment="Center"/>
View uwp-clock-one-frame.xaml
<Grid Background="#242631" Height="400" Width="400" VerticalAlignment="Center" HorizontalAlignment="Center">
<Border x:Name="ClockEllipse" CornerRadius="400" Background="#323443"/>
</Grid>
@tmacharia
tmacharia / ZoneExts.cs
Last active Nov 16, 2019
For achieving a high level of accuracy in detecting the location a machine/user in .NET/C# without location/gps permissions, this helper class contains a bunch of methods & properties to achieve using the machine's LocalTimeZone and looking it up against a known list of timezone info schema that maps to a country's 2-Letter ISO Code.
View ZoneExts.cs
namespace Common
{
using System.Linq;
public class ZoneInfo
{
/// <summary>
/// 2-Letter ISO code representing the country where the timezone is.
/// </summary>
public string Code { get; set; }
/// <summary>
@tmacharia
tmacharia / aspnet-core-get-user-ipaddress.cs
Created Sep 4, 2019
Asp.Net Core Get Request IpAddress
View aspnet-core-get-user-ipaddress.cs
public static string GetIpAddress(this HttpContext _context, bool tryUseXForwardHeader = true)
{
string ip = string.Empty;
/*-----------------------------------------------------------------------------------
| Todo support new "Forwarded" header (2014)
| https://en.wikipedia.org/wiki/X-Forwarded-For
|
| X-Forwarded-For (csv list): Using the First entry in the list seems to work
| for 99% of cases however it has been suggested that a better (although tedious)