Skip to content

Instantly share code, notes, and snippets.

@ndreckshage
ndreckshage / query.tsx
Created January 28, 2022 07:41
example-query
import { useQuery, gql } from "ui/lib/use-data.client";
const Component = () => {
const { data, hydrateClient } = useQuery<{
currentUser?: {
lists: {
id: string;
key: string;
title: string;
}[];
@ndreckshage
ndreckshage / query.js
Last active January 28, 2022 05:43
fql example
const result = await query(Let({
// get author document from index by key. assign authorDoc as variable
authorDoc: Get(Match(Index("unique_authors_by_key"), "haruki-murakami"))
}, Let({
// select book references from author document. assign bookRefs variable
bookRefs: Select(["data", "bookRefs"], Var("authorDoc"))
}, Let({}, {
// start forming the return result here
id: Select(["ref", "id"], Var("authorDoc")),
authorName: Select(["data", "name"], Var('authorDoc')),
@ndreckshage
ndreckshage / layout.server.tsx
Last active January 27, 2022 06:48
layout-mapper
const COMPONENT_MAP = {
LayoutComponent: Layout,
CarouselComponent: Carousel,
GridComponent: Grid,
ListComponent: List,
BookAuthorsComponent: BookAuthors,
BookCategoriesComponent: BookCategories,
BookDetailsComponent: BookDetails,
BookImageComponent: BookImage,
BookTitleComponent: BookTitle,
fragment MarkdownComponentFragment on MarkdownComponent {
id
text
backgroundColor
}
fragment LayoutComponentFragment on LayoutComponent {
id
layoutCreatedBy: createdBy
flexDirection
@ndreckshage
ndreckshage / index.server.tsx
Last active January 27, 2022 04:55
BuzzwordBooklist - Homepage
import Layout from "ui/components/system/layout.server";
export default function HomePage() {
return <Layout id="319284825818136644" />;
}
@ndreckshage
ndreckshage / schema.graphql
Last active January 27, 2022 04:12
BuzzwordBooklist Snippets
type LayoutComponent {
id: ID!
title: String!
createdBy: String!
flexDirection: String!
container: Boolean!
components: [Component!]!
}
union Component =
@ndreckshage
ndreckshage / keybase.md
Created October 5, 2017 01:39
keybase.md

Keybase proof

I hereby claim:

  • I am ndreckshage on github.
  • I am ndreckshage (https://keybase.io/ndreckshage) on keybase.
  • I have a public key ASA21TRez_C6kCPWHrWwBe1gR1TDJZt52bpoq0cZiCGnaAo

To claim this, I am signing this object:

@ndreckshage
ndreckshage / client.js
Created February 15, 2015 21:37
bad auth for shared js
// even though the dangerous auth is fine on client
var cu = require('dangerous-auth').get();
// need to instead shim a context to maintain same api
// to resolve routes etc, sometime need access to context
// var context = {};
@ndreckshage
ndreckshage / client-javascripts-application.coffee
Created January 22, 2014 23:41
snapsecret v3 (node + ember, not all code included)
(->
Ember = require 'ember'
moment = require 'moment'
# Socket.io
io = window.io
host = location.origin.replace /^http/, 'ws'
socket = io.connect host
# SnapSecret
@ndreckshage
ndreckshage / application_controller.js.coffee
Last active January 4, 2016 04:39
snapsecret v2 (not everything included...)
window.SnapSecret.ApplicationController = Ember.Controller.extend
countdownWarning: false
countdown: 60
stats:
totalRead: if !!window.secretStats and !!window.secretStats.totalRead then window.secretStats.totalRead else null
totalSpilled: if !!window.secretStats and !!window.secretStats.totalSpilled then window.secretStats.totalSpilled else null
warnAtTen: (() ->
if @countdown == 10
@set 'countdownWarning', true
else if @countdown > 10