Skip to content

Instantly share code, notes, and snippets.

Avatar
👷‍♂️
Code Janitor

Halil Kayer Kjaer

👷‍♂️
Code Janitor
View GitHub Profile
@Kjaer
Kjaer / 1-setup.md
Created Nov 11, 2022 — forked from troyfontaine/1-setup.md
Signing your Git Commits using GPG on MacOS
View 1-setup.md

Methods of Signing with a GPG Key on MacOS

Last updated September 21, 2022

This Gist explains how to do this using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

There has been a number of comments on this gist regarding some issues around the pinentry-program and M1 Macs. I've finally gotten a chance to try things out on an M1 and I've updated the documentation in 2-using-gpg.md to reflect my findings.

@Kjaer
Kjaer / Graphql_env.sh
Created Jul 31, 2022
Bash script knowledge with environment variables.
View Graphql_env.sh
if [[ "${CYPRESS_ACCOUNT_ID:-}" ]]
then
export GRAPHQL_ACCOUNT_ID=$CYPRESS_ACCOUNT_ID && echo $GRAPHQL_ACCOUNT_ID
else
export GRAPHQL_ACCOUNT_ID=$(grep GRAPHQL_ACCOUNT_ID .env.local | cut -d '=' -f2) && echo $GRAPHQL_ACCOUNT_ID
fi
if [[ "${CYPRESS_API_TOKEN:-}" ]]
then
export GRAPHQL_AUTHORIZATION=$CYPRESS_API_TOKEN && echo $GRAPHQL_AUTHORIZATION
@Kjaer
Kjaer / input.scss
Created Jul 11, 2022
Generated by SassMeister.com.
View input.scss
@use "sass:selector";
@use "sass:string";
@use "sass:map";
.alert{
$alert-class: & !global;
color: green;
display: flex;
border: 1px solid yellow;
}
@Kjaer
Kjaer / good_bad_ugly_code.js
Last active Apr 26, 2022
Good bad and ugly Code
View good_bad_ugly_code.js
// Bad
// Using another condition inside the ternary operator a.k.a nested ternary is bad.
products.filter(({ availableStock, quantity }) => availableStock !== undefined ? quantity <= availableStock : true)
// Ugly
// too many understanding requires, you need to be fully comprehend the double-pipe operator, then read the condition,
// yet code still feels uncertain taste in the mouth.
products.filter(({availableStock, quantity}) => availableStock === undefined || availableStock >= quantity
@Kjaer
Kjaer / Concepts.svg
Last active Oct 10, 2022
Clean + MVVM Architecture
View Concepts.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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"
},