Skip to content

Instantly share code, notes, and snippets.

View hotdang-ca's full-sized avatar

James Robert Perih hotdang-ca

View GitHub Profile
@hotdang-ca
hotdang-ca / distance.go
Last active March 14, 2024 06:58
Golang code to calculate distance between two lat/lng decimal coordinates.
package main
import (
"math"
"fmt"
)
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//::: :::
//::: This routine calculates the distance between two points (given the :::
@hotdang-ca
hotdang-ca / Keypad.tsx
Last active September 8, 2023 08:58
Numeric Keypad in TypeScript React
import * as React from 'react';
import { KeypadKey } from './KeypadKey';
import './styles.less';
export interface IKeypadProps
{
onKeyPressed: (keyPressed: KeypadKeys) => void;
}
@hotdang-ca
hotdang-ca / main.dart
Created April 24, 2023 14:56
Using ChangeNotifier as a Singleton
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() {
runApp(const SampleApp());
}
class SampleApp extends StatelessWidget {
const SampleApp({super.key});
@override
@hotdang-ca
hotdang-ca / FreeCurrencyConverterService.cs
Created November 6, 2018 22:23
C# Service Wrapper around FreeCurrencyConverterApi
using System;
using System.Collections.Generic;
using System.Net;
using System.Web.Script.Serialization;
namespace App.Service.Services
{
public class FreeCurrencyConverterService : IFreeCurrencyConverterService
{
private readonly String BASE_URI = "http://free.currencyconverterapi.com";
@hotdang-ca
hotdang-ca / DetectAdBlock.js
Last active March 1, 2023 09:52
Detect AdBlockers from a React Component
/**
*
* Detect Ad Blockers
*
* Copyright (c) 2017, 2019 Four And A Half Giraffes, Ltd.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
@hotdang-ca
hotdang-ca / query_params.dart
Created February 13, 2023 16:29
Query Params and the Uri Class
void main() {
final String url = "http://www.clickspce.com?foo=bar&fizz=buzz&name=Sebastian";
final Uri parsedUri = Uri.parse(url);
print(parsedUri.queryParameters['foo']);
print(parsedUri.queryParameters['fizz']);
print(parsedUri.queryParameters['name']);
print(parsedUri.queryParameters['probably_null']);
"use strict";
// for better performance - to avoid searching in DOM
const inputElement = document.getElementById('input');
const contentElement = document.getElementById('content');
const statusElement = document.getElementById('status');
// my color assigned by the server
var myColor = false;
// my name sent to the server
@hotdang-ca
hotdang-ca / gcloud_oauth_2_example.dart
Last active September 15, 2022 15:25
Exchange Google Service Account Private Key for OAuth2.0 Token
import 'dart:convert';
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
import 'package:http/http.dart' as http;
const _PATH_TO_SERVICES_JSON = './secrets/service_account.json';
const _GOOGLE_TOKEN_EXCHANGE_URL = 'https://oauth2.googleapis.com/token';
final _cachedToken = <String, DateTime>{};
/// Gets OAuth2.0 access token from a service account json
@hotdang-ca
hotdang-ca / dart_reflection.dart
Last active August 16, 2022 17:30
Exploring Dart Mirrors 1
import "dart:mirrors";
class Product {
String type;
String brand;
String model;
Product(this.type, this.brand, this.model);
}
@hotdang-ca
hotdang-ca / tax_calc.dart
Created June 20, 2022 22:59
fun with tax rates
class ProfitekItem {
late final bool taxable1;
late final bool taxable2;
late final bool taxable3;
late final bool taxable4;
late final num? taxRate1;
late final num? taxRate2;
late final num? taxRate3;
late final num? taxRate4;