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 / 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
"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 / 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 / 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 / example.js
Created July 16, 2019 15:17
CamelCase to Camel Case
console.log("JamesPerihIsCool".replace(/(?<!^)(?=[A-Z])/g, ' '));
/**
*
* Detect Ad Blockers
*
* Copyright (c) 2020 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 / main.dart
Last active March 17, 2022 10:07
Fizzbuzzing Dart
/// Oct 23, 2020
/// Updated March 17, 2021
/// (c) 2020 James Robert Perih c/o Four And A Half Giraffes, Ltd.
void main() {
const int theStart = 1;
const int theEnd = 100;
DartFlutterOutputFactory().printIteration(
from: theStart,
@hotdang-ca
hotdang-ca / singleton_example.dart
Last active May 27, 2021 15:41
Dart Singleton Example
import 'package:flutter/material.dart';
class State with ChangeNotifier {
late num _count;
num get count => _count;
void setCount(newCount) {
_count = newCount;
notifyListeners();
}
@hotdang-ca
hotdang-ca / random_stream.dart
Last active March 17, 2022 10:07
Random Flutter Stream
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:math';
void main() {
runApp(MyApp());
}
class RandomNumberStream {
final StreamController<int> _nextRandomNumberController = StreamController<int>();