Skip to content

Instantly share code, notes, and snippets.

View dmcblue's full-sized avatar

Dan Crawford dmcblue

View GitHub Profile
@dmcblue
dmcblue / compare.js
Last active September 3, 2021 18:15
Javascript Compare
function isObject(v) {
return typeof v === 'object' && v !== null
}
function compare(a, b, indent) {
var toplevel = false;
if (indent === undefined) {
indent = 0;
toplevel = true;
}
@dmcblue
dmcblue / form.ts
Created March 8, 2019 15:18
Cast Event to Submit Event (onsubmit) in TypeScript
/**
* Submit Events have several properties (like 'explicitOriginalTarget') that are not present
* on TypeScript's standard Event type. Straight casting with 'as' does not work so you will
* need to cast as 'unknown' first. (as of TypeScript 3.3.3)
*/
export interface SubmitEvent {
explicitOriginalTarget:HTMLElement
}
const form:HTMLFormElement = document.getElementById('the_form') as HTMLFormElement;
@dmcblue
dmcblue / DeleteRequest.hx
Created February 2, 2019 19:32
How to make a DELETE Request in Haxe
package test;
import haxe.Http;
import haxe.Json;
import haxe.io.BytesOutput;
class DeleteRequest {
static function main() {
var url = "http://some.url/endpoint";
@dmcblue
dmcblue / PatchRequest.hx
Created February 2, 2019 19:30
How to make a PATCH Request in Haxe
package test;
import haxe.Http;
import haxe.Json;
import haxe.io.BytesOutput;
class PatchRequest {
static function main() {
var url = "http://some.url/endpoint";
var data = {
@dmcblue
dmcblue / PutRequest.hx
Last active February 2, 2019 01:05
Make a PUT Request with Haxe
package test;
import haxe.Http;
import haxe.Json;
import haxe.io.BytesOutput;
class PutRequest {
static function main() {
var url = "http://some.url/endpoint";
var data = {