Skip to content

Instantly share code, notes, and snippets.

View czetsuya's full-sized avatar

Ed Legaspi czetsuya

View GitHub Profile
export default interface AuthProps {
user: any,
signOut: any
}
@czetsuya
czetsuya / withUserSession.jsx
Created April 7, 2022 02:17
Wrapper to Amplify's withAuthenticator
import React from 'react';
import Link from 'next/link';
import {
AmplifyProvider,
Authenticator,
Button,
CheckboxField,
Divider,
Flex,
Heading,
@czetsuya
czetsuya / clean_code.md
Created July 6, 2021 00:51 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

package org.hibernate.util;
import java.io.Serializable;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import org.hibernate.HibernateException;
import org.hibernate.StaleObjectStateException;
import org.hibernate.cache.spi.access.EntityDataAccess;
package com.czetsuya.security;
import org.keycloak.adapters.KeycloakDeployment;
import org.keycloak.adapters.KeycloakDeploymentBuilder;
import org.keycloak.adapters.spi.HttpFacade;
import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver;
import org.keycloak.adapters.springboot.KeycloakSpringBootProperties;
import org.springframework.context.annotation.Configuration;
/**
package com.czetsuya.web.application;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
public void initializeSchema(SqlConfiguration entity) {
EntityManager em = entityManagerProvider.getEntityManagerWoutJoinedTransactions();
Session hibernateSession = em.unwrap(Session.class);
hibernateSession.doWork(connection -> {
Database sourceDatabase;
try {
// source changesets
File liquibaseOutFile = File.createTempFile("czetsuyatech-liquibase-out-changeset_" + System.currentTimeMillis(), ".xml");
@czetsuya
czetsuya / Customer
Last active November 27, 2019 12:15
package com.broodcamp.data.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/**
* An Open Source Inventory and Sales Management System
* Copyright (C) 2019 Edward P. Legaspi (https://github.com/czetsuya)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
package com.broodcamp.business.exception;
/**
* @author Edward P. Legaspi | czetsuya@gmail.com
*/
public class GenericException extends RuntimeException {
public GenericException(String msg) {
super(msg);
}