This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as restate from "@restatedev/restate-sdk"; | |
| import { serde } from "@restatedev/restate-sdk-zod"; | |
| import { Stripe } from 'stripe'; | |
| const stripe = new Stripe('STRIPE_KEY'); | |
| const apiHandler = restate.service({ | |
| name: "APIHandler", | |
| handlers: { | |
| async onStripeEvent(ctx, event: Stripe.Event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function chan<T>() { | |
| let p = Promise.withResolvers<T>(); | |
| async function* gen() { | |
| while (true) { | |
| let v; | |
| try { | |
| v = await p.promise; | |
| } catch { | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo yum update -y | |
| sudo yum install -y squid | |
| sudo cat <<EOL > /etc/squid/squid.conf | |
| auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd | |
| auth_param basic realm proxy | |
| auth_param basic children 5 | |
| acl HTTP_ports port 443 | |
| acl HTTP_ports port 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as toml from 'https://deno.land/std@0.207.0/toml/mod.ts'; | |
| async function getStripeConfig() { | |
| const { stdout } = await new Deno.Command('stripe', { | |
| args: ['config', '--list'], | |
| stderr: 'inherit', | |
| }).output(); | |
| return toml.parse(new TextDecoder().decode(stdout)) as any; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function memoize<Args extends unknown[], R>(f: (...args: Args) => R): (...args: Args) => R { | |
| const cache = new Map(); | |
| let retCache: { value: R } | undefined; | |
| return (...args: Args): R => { | |
| if (args.length > 0) { | |
| if (!cache.has(args[0])) { | |
| cache.set(args[0], memoize((...restArgs) => (f as any)(args[0], ...restArgs))); | |
| } | |
| return cache.get(args[0])(...args.slice(1)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graphql from 'graphql'; | |
| const resp = await fetch(url, { method: 'POST', body: JSON.stringify({ query: graphql.getIntrospectionQuery() }), headers: { 'content-type': 'application/json' } }); | |
| const introspectionResult = await resp.json(); | |
| const schema = graphql.buildClientSchema(introspectionResult.data); | |
| const sdl = graphql.printSchema(schema); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { list } from '@keystone-6/core'; | |
| import { graphql } from '@keystone-6/core'; | |
| import { allowAll } from '@keystone-6/core/access'; | |
| import { checkbox, relationship, text, timestamp } from '@keystone-6/core/fields'; | |
| import { select } from '@keystone-6/core/fields'; | |
| import { BaseListTypeInfo, CommonFieldConfig, FieldTypeFunc, fieldType } from '@keystone-6/core/types'; | |
| interface TranslatedFieldConfig< | |
| ListTypeInfo extends BaseListTypeInfo, | |
| LanguageTag extends string, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fetch = require('node-fetch'); | |
| const util = require('util'); | |
| util.inspect.defaultOptions.depth = null; | |
| console.log = (...args) => { | |
| return fetch('https://webhook.site/XXXXX', { | |
| method: 'POST', | |
| body: util.format(...args), | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { mapSchema, getDirective, MapperKind } from '@graphql-tools/utils'; | |
| import { defaultFieldResolver, GraphQLError, GraphQLFieldResolver, GraphQLSchema } from 'graphql'; | |
| function wrapField<Field extends { resolve?: GraphQLFieldResolver<any, any> }>(field: Field, authDirective: Record<string, any>) { | |
| const { resolve = defaultFieldResolver } = field; | |
| field.resolve = (src, args, ctx, info) => { | |
| if (ctx.role !== authDirective.role) throw new GraphQLError(`${authDirective.role} role is needed but your role is ${ctx.role}.`); | |
| return resolve(src, args, ctx, info); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo abc | openssl rsautl -encrypt -pubin -inkey <(ssh-keygen -f <(curl https://github.com/acomagu.keys) -e -m PKCS8) | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa |
NewerOlder