Skip to content

Instantly share code, notes, and snippets.

View arnabkd's full-sized avatar

Arnab Datta arnabkd

View GitHub Profile
import com.fasterxml.jackson.annotation.JsonProperty
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonClass
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.squareup.moshi.internal.Util
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
sealed class Principal
object AnonymousUser : Principal() {
val _empty: String? = null
}
// other implementations of Principal
@arnabkd
arnabkd / cra
Created December 2, 2021 12:31
# Create react-app with typescript
yarn create react-app react-graphql-ts --template typescript
cd react-graphql-ts
mkdir -p src/graphql
cp ../graphql/*.graphql src/graphql
# Deps
yarn add @material-ui/core \
@material-ui/icons \
{
"navn": "Arnab",
"antall": 3
}
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow
import java.time.Duration
suspend fun <T: Any>tickerFlow(
period: Duration,
initialDelay: Duration = Duration.ZERO,
func: () -> T
) = flow<T> {
while (true) {
@arnabkd
arnabkd / setup.sh
Last active June 9, 2021 14:40
setup for Mac
# xcode tools (required)
# xcode-select --install
# Install zsh (required for homebrew)
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# install homebrew
# (highly recommended: makes everything below easier)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
name: CI
on: [push]
jobs:
build:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install
uses: borales/actions-yarn@v2.0.0
import React from 'react'
import { PropTypes } from 'prop-types'
import { Query } from 'react-apollo'
import gql from 'graphql-tag'
const Speaker = ({match}) => {
Speaker.Proptypes = {
match: PropTypes.shape({
params: PropTypes.shape({
id: PropTypes.String
@arnabkd
arnabkd / seed.graphql
Created August 20, 2018 09:28
Solved by using aliases and unique key (email)
mutation{
speaker: createSpeaker(data: {
name: "Name"
email: "example@example.com"
workplace_url: "some_workplace_url"
}){
id
}
talkOne: createTalk(data: {
const express = require('express')
const graphqlHTTP = require('express-graphql')
import schema from './schema'
// The root provides a resolver function for each API endpoint
const root = {
hello: () => 'World'
}
const app = express()