Skip to content

Instantly share code, notes, and snippets.

View sukesh-ak's full-sized avatar

Sukesh Ashok Kumar sukesh-ak

View GitHub Profile
@sukesh-ak
sukesh-ak / HaversineDistance.cs
Last active November 13, 2022 07:53
Spherical Trignometry : HaversineDistance function to find distance between 2 GeoCordinates
/// <summary>
/// Returns the distance in miles or kilometers of any two GeoCordinates
/// Ref: https://en.wikipedia.org/wiki/Haversine_formula
/// </summary>
/// <param name="pos1">Location 1</param>
/// <param name="pos2">Location 2</param>
/// <param name="unit">Miles or Kilometers or Meters</param>
/// <returns>Distance in the requested unit</returns>
public static double HaversineDistance(LatLng pos1, LatLng pos2, DistanceUnit unit)
{
@sukesh-ak
sukesh-ak / SpeedConversionHelperFunctions.cs
Created August 2, 2020 08:13
Helper functions for handling speed conversions while using GNSS
public static double DegreesToRadians(double degrees)
{
return degrees * Math.PI / 180.0;
}
public static double RadiansToDegrees(double radians)
{
return radians * 180.0 / Math.PI;
}
@sukesh-ak
sukesh-ak / SphericalToCartesian.cs
Last active November 13, 2022 07:54
Spherical to Cartesian coordinates
/// Converts Spherical to Cartesian coordinates
int earthRadius = 6367; //radius in km
private Cartesian convertSphericalToCartesian(double latitude, double longitude)
{
var lat = DegreesToRadians(latitude);
var lon = DegreesToRadians(longitude);
var x = earthRadius * Math.Cos(lat) * Math.Cos(lon);
var y = earthRadius * Math.Cos(lat) * Math.Sin(lon);
var z = earthRadius * Math.Sin(lat);
return new Cartesian(x, y, z);
@sukesh-ak
sukesh-ak / interpolate_colors.cs
Created August 11, 2020 15:39 — forked from peterk87/interpolate_colors.cs
C#: Interpolate between 2 colors - 2 different approaches taken from StackOverflow.com
// Interpolate between 2 colors in C#
// Taken from answer by user Jason
// http://stackoverflow.com/questions/1236683/color-interpolation-between-3-colors-in-net
class ColorInterpolator {
delegate byte ComponentSelector(Color color);
static ComponentSelector _redSelector = color => color.R;
static ComponentSelector _greenSelector = color => color.G;
static ComponentSelector _blueSelector = color => color.B;
public static Color InterpolateBetween(
@sukesh-ak
sukesh-ak / DefaultView.cs
Created August 29, 2020 16:06 — forked from dupuyjs/DefaultView.cs
Visual Layer - KeyFrame Animations
#region KeyFrame Animations
ScalarKeyFrameAnimation keyframeAnimation = _compositor.CreateScalarKeyFrameAnimation();
keyframeAnimation.InsertKeyFrame(0.0f, 0.0f); // Optional
keyframeAnimation.InsertKeyFrame(1.0f, 360.0f, _compositor.CreateLinearEasingFunction());
keyframeAnimation.Duration = TimeSpan.FromSeconds(3);
keyframeAnimation.IterationBehavior = AnimationIterationBehavior.Forever;
@sukesh-ak
sukesh-ak / i2c_scanner.ino
Last active November 12, 2020 22:18
i2c_scanner - useful when you are not sure of the i2c address for an i2c device. Works on multiple microcontroller
#include <Wire.h>
void setup() {
Serial.begin (115200);
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++)
@sukesh-ak
sukesh-ak / notebook_launcher.py
Created August 11, 2021 10:13 — forked from timo/notebook_launcher.py
branded ipython notebook launcher
"""==============================
Branded IPython Notebook Launcher
=================================
Executing this module will create an overlay over ipython notebooks own static
files and templates and overrides static files and templates and copies over all
example notebooks into a temporary folder and launches the ipython notebook server.
You can use this to offer an interactive tutorial for your library/framework/...
@sukesh-ak
sukesh-ak / Socks5.cs
Created August 15, 2021 10:56 — forked from zHaytam/Socks5.cs
A Socks5 implementation in .NET Core (C# 8)
using System;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Socks
{
public static class Socks5
@sukesh-ak
sukesh-ak / README.md
Last active October 26, 2023 10:15
How to Convert OVA to VHDX

How to convert OVA to VHDX

  • Rename .OVA file to .7z
  • Use winrar to extract .vmdk out of it

Read here and install qemu (extract zip file)

https://cloudbase.it/qemu-img-windows/

qemu-img convert "D:\VirtualBox\Open-disk001.vmdk" -O vhdx -o subformat=dynamic "D:\VirtualBox\Open.vhdx"

@sukesh-ak
sukesh-ak / sqlite_to_json.sql
Created May 30, 2022 09:10 — forked from akehrer/sqlite_to_json.sql
SQLite Results as JSON using the SQLite JSON1 extension
-- When SQLite is compiled with the JSON1 extensions it provides builtin tools
-- for manipulating JSON data stored in the database.
-- This is a gist showing SQLite return query data as a JSON object.
-- https://www.sqlite.org/json1.html
-- An example table with some data
CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL,
full_name TEXT NOT NULL,
email TEXT NOT NULL,