Skip to content

Instantly share code, notes, and snippets.

Avatar
👷‍♂️
Code Janitor

Halil Kayer Kjaer

👷‍♂️
Code Janitor
View GitHub Profile
@Kjaer
Kjaer / proxy.js
Created Feb 7, 2020 — forked from beradrian/proxy.js
CORS proxy with node-http-proxy
View proxy.js
/** If you want to use the local development environment with the dev backend,
* this will create a proxy so you won't run into CORS issues.
* It accepts the following command line parameters:
* - port the port where the proxy will listen
* - target the DEV backend target to contact.
* Example: If you set the port to 3000 and target to https://dev.nibo.ai then
* your actual "resourceBaseUrl" in NiboSettings should be http://localhost:3000/api/v1
*/
// Define the command line options
const optionDefinitions = [
@Kjaer
Kjaer / iteration_of_collections.js
Created Jan 30, 2020
Performance tips for O(n²) on JavaScript iterations.
View iteration_of_collections.js
function charUnique(s) {
var r = {},
i, x;
for (i = s.length - 1; i > -1; i--) {
x = s[i];
if (r[x])
return false;
r[x] = true;
}
return true;
@Kjaer
Kjaer / jest.config[2].js
Created Oct 15, 2019
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
View jest.config[2].js
module.exports = {
"testEnvironment": "node",
"roots": [
"<rootDir>/components"
],
"preset": 'ts-jest',
"setupFilesAfterEnv": ["<rootDir>/tests/setupTests.ts"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
@Kjaer
Kjaer / tsconfig.jest.json
Last active Oct 15, 2019
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
View tsconfig.jest.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"jsx": "react"
}
}
@Kjaer
Kjaer / jest.config[1].js
Last active Oct 15, 2019
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
View jest.config[1].js
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 Oct 15, 2019
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
View Button.spec.tsx
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 Oct 15, 2019
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
View setupTest[v1].js
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 Oct 15, 2019
"Setting up Jest and Enzyme for Typescript Next.js apps" post gists
View package[final].json
{
"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": {
View gist:4fc5c33a96516cf310c307a44c290304

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
View missing_integer.js
/**
* 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.
*
You can’t perform that action at this time.