Skip to content

Instantly share code, notes, and snippets.

View Kjaer's full-sized avatar
👷‍♂️
Code Janitor

Halil Kayer Kjaer

👷‍♂️
Code Janitor
View GitHub Profile
@Kjaer
Kjaer / tsconfig.jest.json
Last active October 15, 2019 15:28
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
{
"extends": "./tsconfig.json",
"compilerOptions": {
"jsx": "react"
}
}
@Kjaer
Kjaer / jest.config[1].js
Last active October 15, 2019 15:22
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
module.exports = {
"testEnvironment": "node",
"roots": [
"<rootDir>/components"
],
"preset": "ts-jest",
"setupFilesAfterEnv": ["<rootDir>/tests/setupTests.ts"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
@Kjaer
Kjaer / Button.spec.tsx
Last active October 15, 2019 10:19
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
import React from 'react';
import { mount } from 'enzyme';
test('hello world', () => {
 const wrapper = mount(<p>Hello Jest!</p>);
 expect(wrapper.text()).toMatch('Hello Jest!');
});
@Kjaer
Kjaer / setupTest[v1].js
Created October 15, 2019 08:18
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
// Configure Enzyme with React 16 adapter
Enzyme.configure({ adapter: new Adapter() });
@Kjaer
Kjaer / package[final].json
Created October 15, 2019 08:11
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
{
"name": "our-cool-nextjs-app",
"version": "0.1.0",
"dependencies": {
"next": "^9.1.1",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"tslib": "^1.10.0"
},
"scripts": {

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@Kjaer
Kjaer / missing_integer.js
Created April 13, 2019 15:51
Missing Integer
/**
* MISSING INTEGER
* ---
* Write a function:
* function solution(A);
* that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
* For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.
* Given A = [1, 2, 3], the function should return 4.
* Given A = [−1, −3], the function should return 1.
*
@Kjaer
Kjaer / revert-a-commit.md
Created March 7, 2019 13:23 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@Kjaer
Kjaer / algo.js
Last active April 8, 2019 10:23
find longest same char
/*
Algorithmic task
Given a string of length 1048576,
find the position of the longest substring made from identical characters.
It is guaranteed that there is only one such substring and its length is 8192.
You are not allowed to peek inside the string, however you can call an external
function "getMaxLength(int startPosition, int endPosition)" which will return
the longest number of identical consecutive characters found within the interval.

ARCH OVERVIEW

COMPONENTS

CENTER
  • has many clusters.
  • passes down the minimum and maximum server count
  • passes down available apps for the cluster

CLUSTER