Skip to content

Instantly share code, notes, and snippets.

Thomas Reggi reggi

Block or report user

Report or block reggi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@reggi
reggi / question-nestjs-graphql-nested-resolvers.md
Last active Nov 28, 2019
How do I have nested resolvers in nestjs / type-graphql?
View question-nestjs-graphql-nested-resolvers.md

I am trying to find a way that a resolver can essentially return another resolver using [nest.js][1] for creating [Resolvers][2], and [type-graphql][3] to create [object types][4].

Here's an example with the star-wars graphql api

{
  allVehicles(first: 1, last: 100) {
    vehicles {
      name
View serviceState.ts
export function ServiceState<G>(): new () => { value?: G, set(type: G): G }
export function ServiceState<G>(type: G): new () => { value: G, set(type: G): G }
export function ServiceState<G>(type?: G) {
return class ServiceState {
value: G | undefined
constructor() {
this.value = type
}
View Fox.ts
namespace Fox {
export namespace Suppress {
type ThenArg<T> = T extends Promise<infer U> ? U : T
type ReturnAdd<T extends Func, G> = ReturnType<T> extends Promise<infer U> ? Promise<ThenArg<ReturnType<T>> | G> : ReturnType<T> | G
export type Func = (...args: any[]) => any
export type Return<T extends Func> = ReturnAdd<T, undefined>
}
View first-prophecy.ts
import {journey} from '@reggi/journey'
import * as lodash from 'lodash'
const getPairs = (obj) => lodash.entries(obj).map(([key, method], index) => ({key, method, index}));
const nestedReduce = (pairs, cb) => {
return pairs.reduce((acq, fromPair) => {
acq[fromPair.key] = pairs.reduce((acq, toPair) => {
const r = cb({ fromPair, toPair });
if (r) acq[toPair.key] = r;
View universal-overloading.ts
const libs = []
export enum Types {
number,
numbers,
string,
buffer,
}
export enum Actions {
View lodash.d.ts
declare const lodash: typeof import('lodash')
export = lodash
View life.ts
enum Outing {
COMEDY,
DJ_DANCE_PARTY,
SIT_DOWN_LIVE_MUSIC,
BOARD_GAME_NIGHT,
MOVIE,
CONCERT,
THEATER,
DANCE_PROFORANCE,
BILLIARDS,
@reggi
reggi / dates.txt
Created Oct 10, 2018 — forked from azampagl/statetmzs.py
State to timezone conversion.
View dates.txt
Pacific/Apia (GMT-11:00) Samoa Standard Time (Apia)
Pacific/Pago_Pago (GMT-11:00) Samoa Standard Time (Pago Pago)
Pacific/Honolulu (GMT-10:00) Hawaii-Aleutian Standard Time
America/Adak (GMT-09:00) United States (Adak)
America/Anchorage (GMT-08:00) Alaska Daylight Time
America/Ensenada (GMT-08:00) Pacific Standard Time
America/Mazatlan (GMT-07:00) Mountain Standard Time (Mazatlan)
America/Phoenix (GMT-07:00) Mountain Standard Time (Phoenix)
America/Los_Angeles (GMT-07:00) Pacific Daylight Time (Los Angeles)
America/Vancouver (GMT-07:00) Pacific Daylight Time (Vancouver)
View node-challenge.js
var fs = require('fs')
var axios = require('axios')
var _ = require('lodash')
const bb = require('bluebird')
bb.promisifyAll(fs)
async function example () {
const file = await fs.readFileAsync('./urls.txt','utf8')
const urls = file.split('\n')
const action = await bb.map(urls, async (url) => {
View p.js
The idea is simple, all variables defined within a function are always returned and accessable outside of the function, no variables are ever "locked" inside a function.
* If it's called within a Prophesy the values declared within all Prophesys are retained in a shallow object.
* If it's called outside a Prophesy only the return property is returned.
* If there is no return property all properties are returned.
* Everything is maintained in a plain "Object". `{}`
```javascript
const add = new Prophesy((a, b) => [
() => ({a, b}),
You can’t perform that action at this time.