Skip to content

Instantly share code, notes, and snippets.

@lprhodes
lprhodes / graphUtils.js
Last active March 11, 2024 10:21
GraphQL JS (ES6): Convert GraphQLObjectType to GraphQLInputObjectType
// GraphQL Utils
// Module Vars
import {
graphql,
GraphQLObjectType,
GraphQLInputObjectType,
GraphQLID
} from 'graphql';
import { isInputType } from 'graphql/type/definition';
@lprhodes
lprhodes / convertCdkToCloudFormationTemplate.sh
Last active December 22, 2022 07:25
A script that will create a Formation template from a CDK script and also create its assets. To be used along side SAM and tsc-watch for real-time lambda updates.
#!/bin/bash
# This script is designed to replace the existing cdk.out asset directory used by SAM
# otherwise a new asset directory will be created that can't be seen by SAM until SAM is re-run.
echo "Creating cdk output directory"
mkdir -p tmp/cdk.out
ASSET_DIRS=($(ls -d1 tmp/cdk.out/asset*))
DIR_COUNT=${#ASSET_DIRS[*]}
@lprhodes
lprhodes / bookmarks.ts
Created September 1, 2022 07:56
Relay Pagination Mock
// React Component
function ProfileBookmarksScreen(props): JSX.Element {
const { componentId, relayPagination } = props
const { data: user, loadNext, hasNext, refetch } = relayPagination
return (
<>
<div>
{(user?.bookmarkedPostsWithCursor?.edges ?? []).map((edge) => {
@lprhodes
lprhodes / .eslintrc.json
Created April 19, 2022 20:25
Parenthoods opinionated eslint, tsconfig and prettier
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
@lprhodes
lprhodes / blockIssue
Created March 28, 2012 15:56
//Return type 'id' must match previous return type 'void *' when block literal has unspecified explicit return type
//Return type 'id' must match previous return type 'void *' when block literal has unspecified explicit return type
typedef id (^AEURLResponseProcessor)(NSURLResponse *, id, NSError **);
+ (AEURLResponseProcessor)statusCode:(NSIndexSet *)acceptableCodes {
return [[^(NSURLResponse *response, id data, NSError **error){
if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
if (error) {
*error = [AEExpect error:AEExpectResponseNotHTTPError
@lprhodes
lprhodes / libPusher.crash
Created February 29, 2012 17:55
libPusher Crash Log
Incident Identifier: 670E5206-9295-4BC1-891C-E767AF9A7FAD
CrashReporter Key: 8032dfc4784a8d5e1721794ced3590db04cdef21
Hardware Model: iPhone4,1
Process: PusherApp [2188]
Path: /var/mobile/Applications/2F3C771A-8428-49BC-BFF1-9BE8A5BE2CB3/Football Feeder.app/Football Feeder
Identifier: PusherApp
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
@lprhodes
lprhodes / hueRotation.FSH
Created February 20, 2012 23:41
hue rotation
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
uniform lowp float hueAdjust;
precision mediump float;
// no need to compute these...
const float sqrt2 = 1.414213562373095;
const float sqrt3 = 1.732050807568877;
const float oneoversqrt2 = 0.707106781186548;
const float oneoversqrt3 = 0.577350269189626;
@lprhodes
lprhodes / Cappuccino Variable Row Error Example
Created March 15, 2011 04:48
An error with the CPTableView not displaying when first shown
@import <Foundation/CPObject.j>
@implementation QuestionListViewController : CPView
{
CPView view;
CPDictionary questions;
CPRect bounds;
@lprhodes
lprhodes / QuestionListView.j
Created March 15, 2011 05:33
A more clean but still broken version
/*
* AppController.j
* blah
*
* Created by You on March 15, 2011.
* Copyright 2011, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@lprhodes
lprhodes / gist:7d5c99abfa60217eb4a7
Created August 5, 2014 04:24
processing of userDataQueue item.
processQueueItem = function(value, callback) {
var queueObj = value;
var adjustment = queueObj.adjustment;
var userUID = queueObj.userUID;
var obj = queueObj.obj;
var objs = queueObj.objs;
//We can store multilpe objects within a single queue'd item so that they get processed together.
if (objs) {