Skip to content

Instantly share code, notes, and snippets.

View koechkevin's full-sized avatar
💭

KEVIN KOECH koechkevin

💭
View GitHub Profile
import React, { CSSProperties, FC, useCallback, useEffect, useState } from 'react';
import { VariableSizeList as List } from 'react-window';
import xmlHttpRequest from 'axios';
import classes from './app.module.scss';
interface Prop {
index: number;
style: CSSProperties;
}
const paginator = (array, pageSize, pageNumber) => {
const page = pageNumber - 1;
const data = array.slice(page * pageSize, pageNumber * pageSize)
return data;
}
@koechkevin
koechkevin / ts.ts
Created August 20, 2019 14:31
typescript
attachStoryWithSummary = (remoteStory: Story, jiraStory: any) => {
const { fields: { summary, description }} = jiraStory;
const story: Story = { ...remoteStory, summary, description };
const { source: {type: store, externalId}, id: internalId} = story;
this.unifiedTaskStoreService.addStory(story);
this.unifiedTaskStoreService.addLookUp(store, internalId, externalId);
}
// attach with parent internalId, save task in local store
saveTaskInLocalStore = (parentId: string, task: Task): void => {
@koechkevin
koechkevin / proxyServer.js
Last active July 4, 2019 14:23
proxy server
const express = require('express');
const path = require('path');
const proxy = require('express-http-proxy');
const dotenv = require('dotenv');
// Bind heroku port from environment variables or assign the port number 4200 when tested on a different environment.
dotenv.config();
const port = process.env.PORT||4200;
// Create an express server.
.dashboard {
.dashboard-contents {
margin: 1em 2em;
}
.trends-upsell{
display: inline-grid;
grid-template-columns: repeat(2, min-content);
height: 40vh;
min-height: 280px;
grid-gap: 1vw;
.my-circle {
height: 3px;
width: 100%;
position: relative;
overflow: hidden;
background-color: #ddd;
}
.my-circle::after {
display: block;
position: absolute;
css
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
ul {
padding: 3em;
@koechkevin
koechkevin / addVisa.js
Created March 9, 2019 10:45
Apprenticeship contributions using React, Redux and sagas
// actions
export const createTravelReadinessDocument = (documentType, payload) => ({
type: 'CREATE_TRAVEL_READINESS_DOCUMENT',
payload,
documentType
});
export const createTravelReadinessDocumentSuccess = (response) => ({
type: 'CREATE_TRAVEL_READINESS_DOCUMENT_SUCCESS',
response
@koechkevin
koechkevin / controller.js
Last active January 27, 2019 10:17
Pagination
listEmailTemplates(req, res) {
try {
const limit = 6;
const { query: { page, search } } = req;
const data = search
? await models.ReminderEmailTemplate.findAndCountAll(searchEmailTemplates(search))
: await models.ReminderEmailTemplate.findAndCountAll({ paranoid: false });
const { count } = data;
const pageCount = Math.ceil(count / limit);
const currentPage = page < 1 || !page || pageCount === 0 ? 1 : Math.min(page, pageCount);
from django.test import RequestFactory, TestCase
class TestUsers(TestCase):
def setUp(self):
self.factory = RequestFactory()
self.user = User.objects.create_user(
username='koech',
email='kevin@gmail.com',
password='Kev#12345'
)