Skip to content

Instantly share code, notes, and snippets.

View manafire's full-sized avatar

Brad Carson manafire

View GitHub Profile
@jacob-ebey
jacob-ebey / react-use.ts
Last active December 31, 2022 00:46
A very naive implementation of React's use() hook
// A very naive implementation of React's use() hook you can copy and paste into your app today
// to use with solutions such as remix's experimental `defer()` feature.
function use<T>(useable: Promise<T> | T) {
if (typeof useable != "object" || !useable || !("then" in useable)) {
return useable;
}
let promise = useable as Promise<T> & { _data?: T; _error?: unknown };
if ("_data" in promise) {
import invariant from "tiny-invariant";
class AmalgoBox extends HTMLElement {
get input() {
return this.querySelector("input") as HTMLInputElement;
}
get button() {
return this.querySelector("button") as HTMLButtonElement;
}
@kiliman
kiliman / README.md
Last active June 20, 2024 20:46
Debug server-side Remix using VSCode

💡 HOWTO: Debug your server-side Remix code using VSCode

✨ New in Remix v1.3.5

The latest release of Remix fixes sourcemaps so you no longer need to use any hacks to set breakpoints in your route modules. Simply start the debugger and Remix will hit the breakpoint in your loaders and actions.

Debugging session even survives edits and Live Reload.

@tomsoderlund
tomsoderlund / Map.js
Created June 22, 2020 09:50
Using fitBounds in ReactMapGL to center points on map
import React, { useState } from 'react'
import ReactMapGL, { Marker, WebMercatorViewport } from 'react-map-gl'
const applyToArray = (func, array) => func.apply(Math, array)
const getBoundsForPoints = (points) => {
// Calculate corner values of bounds
const pointsLong = points.map(point => point.coordinates._long)
const pointsLat = points.map(point => point.coordinates._lat)
const cornersLongLat = [
@FilledStacks
FilledStacks / stacked_snippets.json
Last active January 2, 2024 04:09
Flutter / Stacked snippets for productivity
{
"Freezed model": {
"prefix": "frz",
"body": [
"@freezed",
"class ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} with _$${1} {",
" factory ${1}({",
" required ${2:String id},",
" }) = _${1};",
"}"
@rohan20
rohan20 / flutter_google_maps_bottom_sheet.dart
Last active July 4, 2023 15:38
Flutter Google Maps Bottom Sheet
import 'package:flutter/material.dart';
class GoogleMapsClonePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
CustomGoogleMap(),
CustomHeader(),
@mosheduminer
mosheduminer / dropzone.dart
Created December 24, 2019 12:51
Implementation of a drag-and-drop zone for flutter web. Inspired by https://gist.github.com/PlugFox/ffe83a91ce50f9c78a5b1d6674e36d1b
import 'dart:async';
import 'dart:html';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
enum _DragState {
dragging,
notDragging,
}
@jfangonilo
jfangonilo / factorybot_faker_demo.md
Last active November 16, 2023 04:28
FactoryBot/Faker Demo

FactoryBot/Faker Demo

For Turing BE Mod2 - MiniShop

https://github.com/turingschool-examples/mini_shop

Are you sick of writing fake data for tests? If you are, then your test files probably look something like this. This is what your index spec probably looks like for a project like MiniShop. You create 3 merchants and 3 items for each merchant and make sure those items show up on your index page...

#index_spec.rb
require "rails_helper"
@brianegan
brianegan / ez_animated_list.dart
Created March 5, 2019 18:55
An AnimatedList that does all the hard work for ya.
library ez_animated_list;
import 'package:flutter/widgets.dart';
typedef EzAnimatedItemBuilder<T> = Widget Function(
BuildContext context,
Animation<double> animation,
T item,
);
@ProjectInitiative
ProjectInitiative / FlutterLicense.dart
Created January 29, 2019 19:39
A quick example of how to implement a licence page and license dialog in Flutter.
// FlutterLicense utility class
import 'package:flutter/foundation.dart';
class FlutterLicense extends LicenseEntry {
final packages;
final paragraphs;
FlutterLicenses(this.packages, this.paragraphs);
}