Skip to content

Instantly share code, notes, and snippets.

View devuxer's full-sized avatar

Dan M. devuxer

View GitHub Profile
function MyComponent({ isOpen }) {
if (!isOpen) return null;
const store = useContext(StoreContext);
// ...
}
@devuxer
devuxer / finale-rest.d.ts
Created October 2, 2018 02:52
TypeScript type definition file for finale-rest
declare module "finale-rest" {
import { Express, Request, Response, Router } from "express";
import { Instance, Sequelize } from "sequelize";
function initialize(options: InitializeOptions): Finale;
function resource(options: ResourceOptions): Resource;
interface Finale {}
@devuxer
devuxer / epilogue.d.ts
Last active September 14, 2018 17:22
TypeScript type definitions for epilogue
declare module "epilogue" {
import { Express, Request, Response, Router } from "express";
import { Instance, Sequelize } from "sequelize";
function initialize(options: InitializeOptions): Epilogue;
function resource(options: ResourceOptions): Resource;
interface Epilogue {}
@devuxer
devuxer / postgraphile.d.ts
Last active June 5, 2018 17:26
postgraphile typings file proposal
declare module "postgraphile" {
import { GraphQLError, ExecutionResult } from "graphql";
import { Pool, PoolConfig } from "pg";
import { IncomingMessage, ServerResponse, Server } from "http";
import * as jwt from "jsonwebtoken";
import { createPostGraphileSchema, watchPostGraphileSchema } from "postgraphile-core";
export type mixed = {} | string | number | boolean | undefined | null;
export type PluginHookFn = <T>(hookName: string, argument: T, context?: {}) => T;
export type AddFlagFn = (optionString: string, description: string, parse?: (option: string) => mixed) => AddFlagFn;
@devuxer
devuxer / postgraphile-core.d.ts
Last active May 5, 2018 23:01
postgraphile-core typings file proposal
declare module "postgraphile-core" {
import { Client, Pool } from "pg";
import { Build, Context, Options, Plugin } from "graphile-build";
type PostGraphileOptions = {
dynamicJson?: boolean;
classicIds?: boolean;
disableDefaultMutations?: string;
nodeIdFieldName?: string;
graphileBuildOptions?: Options;
@devuxer
devuxer / graphile-build.d.ts
Last active May 5, 2018 23:01
graphile-build typings file proposal
// todo verify TypeScript's `[key: string]: any` is equivalent to flow's `[string]: mixed`
// todo verify TypeScript's Build & BuildExtensions is equivalent to flow's build: { ...Build, ...BuildExtensions }
declare module "graphile-build" {
import { GraphQLInterfaceType } from "graphql";
import { EventEmitter } from "events";
import { GraphQLResolveInfo, GraphQLType, GraphQLNamedType, GraphQLSchema } from "graphql";
type TriggerChangeType = () => void;
export type WatchUnwatch = (triggerChange: TriggerChangeType) => void;
@devuxer
devuxer / gist:a618d6b298ca11539fdf21f0aed0f34a
Created February 4, 2018 19:46
Account State (TypeScript)
export type AccountState =
"Active" |
"RegisteredPendingEmailValidation" |
"RegisteredPendingAdminApproval" |
"PasswordResetPendingEmailValidation" |
"EmailChangedPendingValidation";
@devuxer
devuxer / Nancy_IModelValidationSummary.cs
Last active August 29, 2015 13:56
Suggested IModelValidationResult for Nancy
public interface IModelValidationResult
{
public IEnumerable<ModelValidationError> ModelErrors { get; set; }
// one error per pair/group of properties -> show ModelErrorMesssage in error summary list
public IDictionary<string, ModelValidationError> PropertyErrors { get; set; }
// on error per property -> turn property red and show PropertyErrorMessage next to property
// note: would include only the *first* error encountered for each property
public IDictionary<string, IList<ModelValidationError>> GroupedPropertyErrors { get; set; }
@devuxer
devuxer / HtmlWizard.cs
Last active December 21, 2015 12:08
I was curious if I could build a C# "tag builder" that comes close to the succinctness of the Parrot view engine (https://github.com/ParrotFx/Parrot). This is purely hypothetical at the moment (i.e., HtmlWizard does not really exist), but I believe something very close to this would be possible. Do you like the syntax? Do you think it would be e…
public HtmlWizard GetWelcomeView
{
var model = new { Features = new[] { "Easy to type", "Easy to read", "Easy to maintain" } };
return new HtmlWizard((e /* element */, a /* attribute */, ca /* custom attribute */) =>
{
e.Html(
e.Head(
e.Title("Check out ", e.Strong("HTML Wizard"), "!")),
e.Body(