Skip to content

Instantly share code, notes, and snippets.

View nickhudkins's full-sized avatar

Nick Hudkins nickhudkins

View GitHub Profile
@nickhudkins
nickhudkins / cloudfront-trailing-slash.js
Created July 24, 2024 22:22
Trailing Slash CloudFrontFunction
function handler(event) {
const request = event.request;
const uri = request.uri;
const parts = uri.split("/");
const lastPart = parts[parts.length - 1];
const isAssetRequest = lastPart.includes(".");
const isDirectoryRequest = uri.endsWith("/");
const needsTrailingSlash = !isAssetRequest && !isDirectoryRequest;
if (needsTrailingSlash) {
const host = request.headers.host.value;
@nickhudkins
nickhudkins / LocaleSupport.scala
Created October 6, 2021 00:23
Sangria Snippets
// When using an Input field in which you would like to enforce validation at query validation time
// via.... types, you will need a custom JSON marshaller, as well as a `ScalarType` to allow for...
// custom scalar types to be used as an Input. This does not come up as often for custom output types
// as `.toString` allows for most complex types to be easily serialized as a `String`
object LocaleSupport {
import io.circe.Decoder
private val VIOLATION_MESSAGE = "Invalid Locale Provided"
// Custom Java Exception
@nickhudkins
nickhudkins / Fetchers.scala
Created December 18, 2020 14:37
Relationship Fetchers
import sangria.execution.deferred.{Fetcher, HasId, Relation, RelationIds, SimpleRelation}
object Fetchers {
/*
The following three methods are intended to be representative
of whatever your DAO may provide.
*/
def recipesForUsers(ids: Seq[Id[User]]): Future[Seq[Recipe]] = Future {
Recipe(id = 3, foodId = 2, userId = 3) :: Nil
}
cask 'appium' do
version '1.10.0'
sha256 '62257dc78097c399fb9a823f649655f4022f400b'
# github.com/appium/appium-desktop was verified as official when first introduced to the cask.
url "https://github.com/appium/appium-desktop/releases/download/v#{version}/Appium-#{version}.dmg"
appcast 'https://github.com/appium/appium-desktop/releases.atom'
name 'Appium Desktop'
homepage 'https://appium.io/'
@nickhudkins
nickhudkins / createFragmentContainer.js
Last active July 30, 2021 16:18
Data Masking with Apollo / GraphQL Anywhere
import React from 'react';
import { filter } from 'graphql-anywhere';
import hoistNonReactStatic from 'hoist-non-react-statics';
/*
* createFragmentContainer returns a component which expects props that match
* WrappedComponent's fragment names, and provides data masking
*/
export default function createFragmentContainer(WrappedComponent) {
@nickhudkins
nickhudkins / keybase.md
Created August 4, 2017 14:10
keybase.md

Keybase proof

I hereby claim:

  • I am nickhudkins on github.
  • I am nickhudkins (https://keybase.io/nickhudkins) on keybase.
  • I have a public key ASD1laRxhHGiUOyrE0CJafJIJnwfFRjXWYgTLe6MJY_XsAo

To claim this, I am signing this object:

@nickhudkins
nickhudkins / SampleGistEmbed.js
Created January 18, 2017 15:35
Just a little gist
export default ({ awesome }) => awesome.map(({ very }) => very
const myAction = () => {
return (dispatch) => {
dispatch(this)
dispatch(that)
dispatch(otherThing)
dispatch(stopDoingthis)
dispatch(whatareyoudoing)
}
}
@nickhudkins
nickhudkins / TodoList.js
Created June 2, 2016 14:23
Relevant Fragment Definitions
/*...*/
fragments: {
viewer: () => Relay.QL`
fragment on User {
todos(status: $status, first: 2147483647) {
edges {
node {
id,
${Todo.getFragment('todo')},
},
@nickhudkins
nickhudkins / BridgeManager.h
Created December 17, 2015 21:16
RN Relay "Reset" LOLROFLCOPTER.
//
// BridgeManager.h
//
// Created by Nick Hudkins on 12/13/15.
//
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
@interface BridgeManager : NSObject <RCTBridgeModule>