Skip to content

Instantly share code, notes, and snippets.

View ragavendra's full-sized avatar

() => { } ragavendra

View GitHub Profile
@ragavendra
ragavendra / DegMinSec.java
Created September 26, 2025 20:30
Degrees to seconds converter, add and subtract.
import java.util.Arrays;
public class DegMinSec {
/*
// calc deg-min-sec to deg
dd = Math.signum(d) * (Math.abs(d) + (m / 60.0) + (s / 3600.0));
// res is in "ddd.mmss" format
jshell> decimal res = Math.signum(6) * (Math.abs(6) + (18 / 60.0) + (34 / 3600.0));
@ragavendra
ragavendra / Annot.java
Created August 7, 2025 20:24
Annotations in Java also Reflection
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
@SomeAnnots(author = "First Last", date = "3/3/2025", currRev = 2, lastMod = "", lastModBy = "", reviewers = {"one", "two" })
public class Annot {
@SomeAnnots(author = "Meth LasMeth", date = "2/2/2025", reviewers = { "fir", "sec" })
@ragavendra
ragavendra / EmailService.cs
Last active June 24, 2024 20:01
Email service DI with Ethereal free fake smtp and Dummy service for non -prod
using System.Net.Mail;
namespace TodoApi.Services
{
public interface IEmailService
{
public Task SendEmail(string email, string body);
}
// For non - prod
@ragavendra
ragavendra / CsharpCallback.cs
Created June 14, 2024 20:38
Callbacks in Csharp like CommonJS style
using System;
using System.Threading.Tasks;
public class Program
{
public static void Main()
{
ReadFile("", (err, data) => {
if(err != null) {
@ragavendra
ragavendra / Program.cs
Created June 4, 2024 22:02
Dotnet new webapi project Dependency Injection
using webapi;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// builder.Services.AddSingleton<ISampleInterface, SampleClass>();