Skip to content

Instantly share code, notes, and snippets.

View scottcorgan's full-sized avatar
💭
Not coding

Scott Corgan scottcorgan

💭
Not coding
  • Tamarack
  • Shelbyville, KY
View GitHub Profile
@scottcorgan
scottcorgan / testing-hooks-with-remix-and-testing-library.tsx
Last active September 15, 2024 19:08
Testing hooks with Remix and Testing Library
/**
* If have any hooks that use Remix hooks, this helper will save you headaches
*/
import { createRemixStub } from "@remix-run/testing";
import { renderHook } from "@testing-library/react";
const renderRemixHook = <T,>(callback: () => T) => {
const RemixStub = ({ children }: PropsWithChildren) => {
const Remix = createRemixStub([
@jacobparis
jacobparis / timing.server.ts
Created April 29, 2023 23:24
Server Timing Utilities for Remix
export type PerformanceServerTimings = Record<
string,
Array<PerformanceServerTiming>
>
/**
* Run this on the server to get a `time` function that can be used to time
* server-side operations and add them to the `Server-Timing` header.
*/
export function getServerTiming() {
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
@kritzcreek
kritzcreek / Kinds-and-do-syntax.md
Last active March 28, 2020 11:51
Kinds and Do-Syntax

Kinds

In PureScript there are types of different kinds. Kinds are types for types. For example Int has kind Type, and we write it as Int :: Type. You can ask for the kind of a type in purs psci

> :k Int
Type

Type constructors take types to other types. For example Array (which still needs another type to form a type a value could have, like Array Int):

@ryanjames
ryanjames / grid-output.css
Created April 19, 2017 03:37
DG grid output
/* line 5, /Users/ryanjames/Sites/desiring-god/app/assets/stylesheets/modules/_grid.scss */
.grid-container {
padding-left: 10px;
padding-right: 10px;
max-width: 400px;
margin-left: auto;
margin-right: auto;
}
/* line 12, /Users/ryanjames/.rvm/gems/ruby-2.4.1/gems/susy-2.2.12/sass/susy/output/support/_clearfix.scss */
.grid-container:after {
@benoitongit
benoitongit / my_vue_component.coffee
Last active May 8, 2021 10:24
Make Vue.js works with Ruby on Rails and Turbolinks 5. Gem is available here: https://github.com/benoitongit/vue-on-rails
@MyComponent =
props: ['myProp']
template: '<div>A custom component with {{myProp}}</div>'
@yang-wei
yang-wei / decode.md
Last active April 2, 2024 20:18
Elm Json.Decode tutorial and cheatsheet

When receiving JSON data from other resources(server API etc), we need Json.Decode to convert the JSON values into Elm values. This gist let you quickly learn how to do that.

I like to follow working example code so this is how the boilerplate will look like:

import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=))

import Http
// from the brilliant mind of sb
var _catch = Promise.prototype.catch;
Promise.prototype.catch = function () {
return _catch.call(this, function (err) { setTimeout(function () { throw(err); }, 0); });
}
@yelouafi
yelouafi / FP_Observables.js
Last active March 1, 2021 05:53
Observables with pure FP
// Observable is an Union Type, with the following variants
const Empty = () => ['EMPTY']
const Cons = (head, tail) => ['CONS', head, tail]
const Future = promise => ['FUTURE', promise]
// race between 2 promises; each promise will resolve to a lazy value
const lazyRace = (p1, p2) => Promise.race([p1,p2]).then(lazy => lazy())
// function composition
const compose = (...fns) => (arg) => fns.reduceRight((res, f) => f(res), arg)
@DrBoolean
DrBoolean / binary_baby.js
Created January 7, 2016 21:04
State Monad is useful example
import State, {get, put, modify} from 'fantasy-states'
import {prop, compose, map, chain, merge, always} from 'ramda'
// Unfortunately Binary Gendered Baby Page
//==========================================
const babies = [{id: 2, name: 'Anjali', sex: 'F'}, {id: 3, name: 'Antonio', sex: 'M'}]
// isFemale :: Baby -> Bool