This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Try.ts | |
// By Colin Teahan | |
// August 14th, 2024 | |
// | |
// This TypeScript file enables usage of the .try() method which will return a result tuple of [T?, Error?] | |
// from any function or async function. This works by defining a new property on the global Object.prototype | |
// and then do some type-fu. | |
// | |
// Example usage: | |
// https://www.typescriptlang.org/play/?target=99#code/MYewdgziA2CmB0w4EMBOAKAlAKGwejwAJCAVVAT3gBcJ8jCAhcwgYRgEsxTZkALZMHWIBBAK4BzURCqEAjABYqvADSEATAAY18ukNK92EUuQAOsAMrBU7EzIBm7OIVhhkAIzhGpycbEIg7QiU-agosQgBbWCUQABNCAHcDYF5Ex2hCVGjRVC5kTNgIUWgZKlETJwDCAG0SAH5VAFFUVBBUOoBdPTtWiMIBZjtRMGAqdnB-VH6IchHCIZGx8Hh9Q0S2gGsjN2ZY2AcwTnF+wjBYBMITVrNUKmYJ4MJxaBA3ZAyAeTcAK1hR+CuICoQNMsD0AniwS4sRAhCgUSCoIAtEN4LoCMRGgAPZARCp+by+ABc6PoC1G4y4vioAFUILBUEwAJKxdDsWJE06iCJuBmYQgAbz0xGI7ECbPiAB4ALyEDT8pStC5nC7NVoYADknAAbu92YQpAzCOyNTgMSLiFkyrlBadcbBORqGK8Nap9QBfPSegh6UCQGTVQ2oVQM9UdQiy6l0hnM2KhcjoeWESVIpHOFptNLQDK8grWs6xX3gaQ1IMhjOocOR6LRxnkFnx9CyfkptNBwhOl3GoxWnIF0nEAByHxIjU5JAMRjW0nSJwSm2NXEB4iyECMEO7pyBcNE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* GenericSubClass | |
* | |
* This class extends a base class (in this case FooType) without having to manually | |
* define all of the base classes properties and methods. This is accomplished using | |
* a Proxy wrapper and a factory method. | |
* | |
* When creating a new instance do not call new GenericSubClass directly, but instead | |
* use the static factory method GenericSubClass.new({ ... }) which will return the | |
* GenericSubClass with a proxy wrapper. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sorted - Utility Type | |
* | |
* Takes a tuple of unsorted numbers and returns a sorted tuple of the | |
* same values in ascending order. Can handle negative as well as | |
* duplicate numbers. | |
* | |
* This works by destructuring the list into [List[0], ...List.slice(1)] | |
* sorting the list slice recursively until the slice is only one element. | |
* Then as we return we insert List[0] at each level into a sorted list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Soladex Corp.</title> | |
<description></description> | |
<script> | |
</script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Soladex Corp.</title> | |
<script> | |
function getAddress(latitude, longitude) { | |
return new Promise(function(resolve, reject) { | |
var request = new XMLHttpRequest(); | |
var method = 'GET'; | |
var url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' + latitude + ',' + longitude + '&sensor=true'; |