Skip to content

Instantly share code, notes, and snippets.

View lorefnon's full-sized avatar

Lorefnon lorefnon

View GitHub Profile
@lorefnon
lorefnon / index.ts
Created January 2, 2024 12:19
Garph Kysely Batch Operation example
import sql, { Database } from "@leafac/sqlite";
import { g, InferResolvers, buildSchema } from 'garph'
import { createYoga, YogaInitialContext } from 'graphql-yoga'
import { createServer } from 'http'
import { groupBy } from "lodash"
import { Generated, Kysely, SqliteDialect } from 'kysely'
// Create in memory db instance
const db = new Database(":memory:");
@lorefnon
lorefnon / 01__usage.ts
Last active June 30, 2020 19:08
React ElFac
import { render } from "react-dom";
import { factoryMap } from "./react-elfac";
import App from "./App";
// Use factoryMap to wrap one or more imported components
const R = factoryMap({
App
});
@lorefnon
lorefnon / flow-pipe.ts
Created May 25, 2020 06:30
MST flowPipe with async/await
// Ref: https://github.com/mobxjs/mobx-state-tree/issues/1516
import { flow } from "mobx-state-tree";
interface PromiseWrapper<T> {
_type: "PromiseWrapper";
resolve: (result: T) => void;
reject: (err: any) => void;
originalPromise: Promise<T>;
wrappedPromise: Promise<T>;
@lorefnon
lorefnon / index.js
Created November 25, 2019 18:13
GRelDAL custom operations without Database interactions
const { mapSchema } = require("greldal");
const { graphql, GraphQLString } = require("graphql");
const customOperation = {
operationType: "query",
name: "printHello",
fieldConfig: {
type: GraphQLString,
description: "Prints hello",
resolve: (obj, args, context, info) => {
@lorefnon
lorefnon / index.js
Created November 25, 2019 18:13
GRelDAL custom operations without Database interactions
const { mapSchema } = require("greldal");
const { graphql, GraphQLString } = require("graphql");
const customOperation = {
operationType: "query",
name: "printHello",
fieldConfig: {
type: GraphQLString,
description: "Prints hello",
resolve: (obj, args, context, info) => {
@lorefnon
lorefnon / README.md
Last active May 19, 2019 10:51
Chevrotain parser for a subset of jq syntax

About

Parses jq-inspired concise object access & transformation syntax using chevrotain

Supported

  • Object member access: .bar.baz
  • Array member access: .[0]
  • Slices: .[0:9]
  • Construction of objects and arrays: {a: .b.c}, {b: .[0].foo}, [.a.b, .c.d]
@lorefnon
lorefnon / .carbon-now.json
Last active April 24, 2019 18:22
Markdown transformer to convert Code blocks to embedded (base64 encoded) images syntax highlighted by carbon.now.sh
{
"latest-preset": {
"t": "dracula",
"bg": "transparent",
"wt": "sharp",
"wc": true,
"fm": "Fira Code",
"fs": "11px",
"ln": false,
"ds": true,
@lorefnon
lorefnon / package.json
Created August 18, 2018 19:44
Integrating next.js, Apollo Server and Koa
{
"main": "server/index.js",
"scripts": {
"dev": "nodemon --watch server server/index.js",
"build": "next build",
"start": "NODE_ENV=production node server/index.js"
},
"dependencies": {
"apollo-boost": "^0.1.13",
"apollo-server": "^2.0.4",
@lorefnon
lorefnon / .spacemacs
Last active January 2, 2018 05:29
Spacemacs config file
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@lorefnon
lorefnon / .emacs
Last active January 22, 2017 19:36
My emacs config
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(show-paren-mode t)
'(tool-bar-mode nil)
'(tooltip-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.