Skip to content

Instantly share code, notes, and snippets.

import React from 'react'
import TitleInput from './TitleInput';
import OptionInput from './OptionInput';
import {withLogic} from "../../utilities/with-logic";
import DataLogic from "./data-logic";
type Option = {
id: string;
text: string;
};
@Yengas
Yengas / 02-render-with-css-example.tsx
Last active February 20, 2020 20:13
Micro-frontend architecture and React with Web Components
import root from 'react-shadow';
import styles from './components/index.scss';
class SellerStoreEditorWebComponent extends HTMLElement {
// ...
private getComponentToRender() {
return (
<root.div>
<SellerStoreEditor />
<style type="text/css">{styles}</style>
@Yengas
Yengas / 01-usage-example.html
Created February 20, 2020 20:00
Micro-frontend architecture and React with Web Components
<html>
<head>
<!-- Seller Partner Panel related code -->
<script src="$public-url/seller-store.vendor.min.js" type="text/javascript"></script>
<script src="$public-url/seller-store.min.js" type="text/javascript"></script>
</head>
<body>
<!-- Seller Partner Panel related code -->
<seller-store-editor />
<!-- Seller Partner Panel related code -->

Clean Code

Introduction

  • Writing clean code is like riding a bike, you can study physics of it, but still fall down the first time you try to do it
  • Programming languages will be created with higher abstractions, and more specific languages related to domains we work will be created(a+), but that doesn’t mean programming will be a lost art. We can’t create machines that do what we want. We can only create machines that can do what we say.

Chapter 1: Clean Code

  • Leblanc’s law: later equals never
# git commit with branch helper
gam () {
MESSAGE="$1"
TASK_ID=$(git branch | grep \* | cut -d ' ' -f2 | perl -l -ne '/[a-z]+\/([A-Z]+\-[0-9]+)($|=)/ && print $1')
if [ -z "$TASK_ID" ]; then
echo "task id not be found. branch examples: feature/RECO-01, feature/RECO-01=long-description"
echo "falling back to normal commit"
git commit -am "$MESSAGE"
elif [ -z "$MESSAGE" ]; then
@Yengas
Yengas / docker-compose.yaml
Created April 21, 2019 08:33
Lobby Menu deployment
version: '3'
networks:
face-network: {}
volumes:
database-storage: {}
services:
database:
build: ./persistence/database
volumes:
- database-storage:/data/db
@Yengas
Yengas / insert-example.scala
Last active November 16, 2018 10:13
Spark At Getir - 01
import org.apache.spark.sql.types._
import org.apache.spark.sql.functions._
case class Order(id: String, userName: String)
val orders = Seq(Order("5b85bda7685ca053517a948b", "Ahmet"), Order("5b85bda764d8194a675a546d", "Mehmet"), Order("5b85bda812c1e568bc6596dc", "Ahmet")).toDS()
orders
.groupBy("userName")
.agg(
first(struct($"id" as "oid")) as "firstOrder",
@Yengas
Yengas / schema-optimization-explain.scala
Created November 15, 2018 16:32
Spark at Getir - 01
// Previous approach to conversion
// definition
def rowToDocument(row: Row): BsonDocument
// usage
rowToDocument(row) // for each line
// The (micro) optimized approach
// definition
def rowToDocumentMapper(schema: StructType): (Row) => BsonDocument
// usage
@Yengas
Yengas / example.md
Last active October 6, 2018 14:27
A python script that compares two branches/commits to see which files where added/deleted/modified/renamed. And also prints out which line ranges where added/deleted.

Usage

# get the diff between current head and master
git-changed-files-and-lines.py master
# get the diff between master and dev
git-changed-files-and-lines.py master dev

Example Result

@Yengas
Yengas / async-await-with-generators.js
Last active June 17, 2018 13:32
Simple implementation of async/await workflow with generators and yield.
function doSomething(){
return Promise.resolve(73);
}
function timeout(ms){
return new Promise((resolve) => setTimeout(resolve, ms, ms));
}
function asyncFlow(generatorFunc){
const generator = generatorFunc();