Skip to content

Instantly share code, notes, and snippets.

View indatawetrust's full-sized avatar
🏠
Working from home

Ahmet Simsek indatawetrust

🏠
Working from home
View GitHub Profile
@indatawetrust
indatawetrust / test.js
Last active May 16, 2020 13:56
expressjs endpoint testing with ava + supertest + @hapi/joi
const test = require('ava')
const request = require('supertest')
const app = require('../lib/infra')
const Joi = require('@hapi/joi')
const agent = request.agent(app)
test('main', async (t) => {
const { body } = await agent.get('/')
import React, {useContext, useState} from "react";
export default null;
const FeathersContext = React.createContext(null);
export const useFeathers = () => useContext(FeathersContext);
export const FeathersProvider = ({ children, client: feathersClient }) => {
const [isLoggedIn, setIsLoggedIn] = useState(false);
version: '3.1'
services:
reverse-proxy:
image: traefik # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Traefik to listen to docker
ports:
- "3000:3000" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
@indatawetrust
indatawetrust / plink-plonk.js
Created February 18, 2020 10:37 — forked from tomhicks/plink-plonk.js
Listen to your web pages
const children = [];
const getChildren = el => [...el.children].map(child => {
getChildren(child);
child.style.transition = 'all ease 0.5s'
children.push(child);
});
getChildren(document.body);
@indatawetrust
indatawetrust / storage.ts
Created December 15, 2019 16:12
capacitor auth storage for featherjs
import { Plugins } from "@capacitor/core";
const { Storage } = Plugins;
export default class CapacitorStorage {
static async getItem(key: string) {
const { value } = (await Storage.get({ key })) || { value: null };
return value;
}
@indatawetrust
indatawetrust / cps.js
Created December 15, 2019 12:16
redux-saga cps effect
const response = yield cps(cb =>
new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, 1000);
}).then(data => cb(null, data))
.catch(error => cb(error))
);
appcenter distribute release -f app-debug.apk -g Collaborators
const messages = app.service('/messages');
messages.on('created', (data) => {
dispatch(services.messages.onCreated(data));
})
messages.on('updated', (data) => {
dispatch(services.messages.onUpdated(data));
})
messages.on('patched', (data) => {
dispatch(services.messages.onPatched(data));
@indatawetrust
indatawetrust / httpClient.js
Created September 25, 2019 07:42
httpClient for react-admin
import {fetchUtils} from 'react-admin';
const httpClient = (url, options = {}) => {
if (!options.headers) {
options.headers = new Headers({Accept: 'application/json'});
}
const token = localStorage.getItem('jwt');
options.headers.set('Authorization', `Bearer ${token.replace(/"/g, '')}`);
return fetchUtils.fetchJson(url, options);
};