Skip to content

Instantly share code, notes, and snippets.

View NoahAndrews's full-sized avatar

Noah Andrews NoahAndrews

View GitHub Profile
@wchargin
wchargin / multiplyFloat.js
Created April 13, 2020 04:24
multiply bigint by float in JS (spoiler alert: BigInt has no useful functions)
/**
* For a finite normal 64-bit float `f`, extracts integers `sgn`,
* `exponent`, and `mantissa` such that:
*
* - `sgn` is -1 or +1
* - `exponent` is between -1023 and 1024, inclusive
* - `mantissa` is between 0 and 2^51 - 1, inclusive
* - the number given by `f` equals `sgn * 2^exponent * (1 + mantissa / 2^52)`
*
* The results are all bigints within the range of safe integers for
@chriseppstein
chriseppstein / DependenciesInPublicAPIs.md
Last active March 28, 2024 04:05
If you keep getting "Two different types with this name exist, but they are unrelated." from TypeScript, here's what you need to do to fix it.

Two different types with this name exist, but they are unrelated.

I'm a little slow, so maybe everyone else already realized this, but after struggling for almost a year with periodic "Two different types with this name exist" error from typescript, I've realized it is actually really helpful error and it highlights a real problem that I've failed to understand until this week.

I've been working around this issue by making sure that my libraries with common dependencies are always on the same version for some of our shared library dependencies. This works because package managers dedup the same version of a dependency. But when the versions diverge you get different instances of the library. In this mode, Good Guy TypeScript is telling us "Hey you're comparing values and types from different instances of the same library and that's a Bad Idea."

package org.firstinspires.ftc.robotcontroller.internal;
import java.lang.Thread.UncaughtExceptionHandler;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
@5484Enderbots
5484Enderbots / ClosableVuforiaLocalizer.java
Created October 1, 2017 17:37
A drop-in replacement for VuforiaLocalizer that can be detached from the camera before the opmode ends.
package org.firstinspires.ftc.teamcode;
import org.firstinspires.ftc.robotcore.internal.vuforia.VuforiaLocalizerImpl;
/**
* Copyright (c) 2017 FTC Team 5484 Enderbots
* 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
@bubbleguuum
bubbleguuum / CachedDocumentFile.java
Last active October 23, 2023 22:26
Improve DocumentFile performance
package android.support.v4.provider;
import android.net.Uri;
import android.support.v4.provider.DocumentFile;
public class CachedDocumentFile extends DocumentFile {
final DocumentFile mWrapped;
final boolean mCacheChildren;
@race604
race604 / adb+
Last active August 20, 2023 09:03
#!/bin/bash
# Script adb+
# Run any command adb provides on all your currently connected devices,
# Or prompt to select one device
showHelp() {
echo "Usage: adb+ [-a] <command>"
echo " -h: show help"
echo " -a: run command on all device"
echo " command: normal adb commands"
@paragonie-scott
paragonie-scott / crypto-wrong-answers.md
Last active August 17, 2024 06:33
An Open Letter to Developers Everywhere (About Cryptography)
@joswr1ght
joswr1ght / colorpromptnewline.txt
Created October 25, 2015 16:43
Colorful Terminal Prompt with Directory on a Separate Line
PS1="\[\033[01;34m\]\w\[\033[00m\]\n\$ "
@benjchristensen
benjchristensen / EventBus.java
Last active February 24, 2022 03:02
EventBus.java
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* Simple pass-thru event bus with error handling and reconnect.
*/
public class EventBus {
@archeg
archeg / gist:8333021
Created January 9, 2014 11:58
Example of code that uses HID for Android to connect to the device through USB.
package com.company.app.PlatformMethods;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;