Skip to content

Instantly share code, notes, and snippets.

View dsdenes's full-sized avatar

Denes Pal dsdenes

View GitHub Profile
fdsfds
@dsdenes
dsdenes / gist.component.spec.tsx
Created December 26, 2019 22:17
gist.component.spec.tsx
import React from 'react'
import { render } from '@testing-library/react'
import { Gists } from './gists.component'
describe('gists.component', () => {
it('should show only the error message if fetching failed', async () => {
const useGists: any = jest.fn(() => [null, 'this is the error'])
const { getByText, queryByText } = render(<Gists useGists={useGists} />)
await getByText('this is the error')
expect(queryByText('Prev')).toBe(null)
export interface Gist {
url: string
}
export const useGists = (page: number = 0): [Gist[] | null, string?] => {
const [gists, setGists] = useState(null)
const [error, setError] = useState()
useEffect(() => {
let mounted = true
interface GistsProps {
useGists: (page?: number) => [Gist[] | null, string?];
}
export const Gists: React.FC<GistsProps> = props => {
const [page, setPage] = useState(0);
const [gists, error] = props.useGists(page);
if (error !== undefined) {
return <div>{error}</div>;
@dsdenes
dsdenes / app.tsx
Last active December 23, 2019 14:19
Fetching in React components, the correct way
import { GistList } from './gists.component'
import { useGists } from './gists.control'
function App () {
const [whichList, setWhichList] = useState(0)
return (
<>
<h1>Fetching GitHub Gists</h1>
<button onClick={() => setWhichList(0)}>List 1</button>
swagger: "2.0"
info:
description: $API_DESCRIPTION
version: $API_VERSION
title: $API_TITLE
host: "api.truckin.io"
basePath: "/v3"
schemes:
- "http"
- "https"
@dsdenes
dsdenes / C3S
Created July 10, 2017 13:40
Hello!
Code review-t kérnénk a meglévő kódbázisra, egyelőre csak backend (~7.000 sor).
A mostani architektúra áttekintése, esetleges szűk keresztmetszetek, problémák kiszűrése
RabbitMQ-t használó microservice-t hogyan lehet unit tesztelni?Hogyan lehet unit tesztet írni AMQP (amqplib) protokollt használó JS alkalmazáshoz, ami nem integration teszt. (Jelenleg integration tesztek vannak, localhost rabbitmq docker image segítségével). Létezik-e JS-hez amqplib mock library (én nem találtam)?
**Mi írtunk egyet: https://github.com/lab-coop/lab-queue/blob/master/implementations/memory/index.js de ez nem tudom, hogy jelenleg production ready-e, illetve exchange kezeles nincs benne.**
Jó-e a jelenlegi architektúra elképzelés RabbitMQ-val? (ts_exchange (topic), routing, log_exchange a logoknak, minden uS ide beszél
Hogyan lenne célszerű megoldani, hogy egy TS önállóan is tudjon működni, ha leszakad a hálózatról, de úgy, hogy a jelenleg megírt AMQP-s modulokat ne kelljen újraírni (TS helyi Rabbit broker?)
@dsdenes
dsdenes / oiwarren.js
Created June 21, 2017 11:54
OIWARREN
function t(r) {
return r[0].toUpperCase() + r.substring(1)
}
this.warren = this.warren || {}, this.warren.angular = this.warren.angular || {}, warren.angular.controller = function(r, e, n) {
n = n || {};
var l = r.replace("warren.", "").split(".")[0],
a = r.replace(/^warren\.\w+\./, "").split("."),
o = a[a.length - 1],
i = a.map(function(r) {
return t(r)
import * as firebase from 'firebase';
const actionNames = {
INPUT_CHANGED: 'INPUT_CHANGED',
TOGGLE_NOTIFICATION: 'TOGGLE_NOTIFICATION',
LOGGEDIN: 'LOGGEDIN',
LOGGEDOUT: 'LOGGEDOUT',
LOGIN_ERROR: 'LOGIN_ERROR'
}
POST /jobs
{
"images": [
"https://somewhere/ImageName1.jpg",
"https://somewhere/ImageName2.jpg",
"https://somewhere/ImageName3.jpg",
"https://somewhere/ImageName4.jpg",
"https://somewhere/ImageName5.jpg",
"https://somewhere/ImageName6.jpg",
"https://somewhere/ImageName7.jpg"