Skip to content

Instantly share code, notes, and snippets.

View christoforosl's full-sized avatar

Christopher Lambrou christoforosl

View GitHub Profile
@christoforosl
christoforosl / .env
Created February 27, 2024 06:05 — forked from degitgitagitya/.env
Next JS + Next Auth + Keycloak + AutoRefreshToken
# KEYCLOAK BASE URL
KEYCLOAK_BASE_URL=
# KEYCLOAK CLIENT SECRET
KEYCLOAK_CLIENT_SECRET=
# KEYCLOAK CLIENT ID
KEYCLOAK_CLIENT_ID=
# BASE URL FOR NEXT AUTH

Database Design Principles

General

  1. Every table should have a SINGLE, SURROGATE and NUMERIC field as the primary key. Never use logically unique fields as primary keys. For example. Do not use IDENTITY_CARD_NO as a primary key on a PERSON table.

  2. In Oracle, use NUMBER (10) incremented by a sequence

  3. In SQL Server/MYSQL use IDENTITY column.

@christoforosl
christoforosl / cleanCode.md
Last active January 12, 2023 12:14 — 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.

    Use CamelCase to name classes, fields and methods. DO NOT USE snake_case in code, except from defining constants.

  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.

  3. Always find root cause. Always look for the root cause of a problem.

mvn -Dmaven.repo.local=[path to clean .m2] -s [cleanSettings.xml] clean install
@christoforosl
christoforosl / killAllUsernameSessions.sql
Created September 11, 2020 08:52
PL/SQL Code to kill all username sessions
begin
for c in( select 'ALTER SYSTEM KILL SESSION '''|| s.sid ||','||s.serial#||''' IMMEDIATE' as stmnt from v$session s where s.osuser='christoforosl' and s.sid != sid)
loop
EXECUTE IMMEDIATE c.stmnt ;
end loop;
end;/
package org.dtph.model;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
*
@christoforosl
christoforosl / TO_NUMBER_FROM_ROMAN_NUMERAL.sql
Last active August 10, 2018 11:04
Oraccle pl/sql function to convert Roman numeral (I, II, II, IIV, etc) to decimal numeral, adapted from https://livesql.oracle.com/apex/livesql/file/content_CESOH7H2D4O88XLW60330Q3L9.html
create or replace function TO_NUMBER_FROM_ROMAN_NUMERAL(p_in varchar2)
return number DETERMINISTIC as
/** adapted from https://livesql.oracle.com/apex/livesql/file/content_CESOH7H2D4O88XLW60330Q3L9.html **/
v_in varchar2(200) := upper(p_in); -- upper case it
v_ret number(10);
begin
v_in := replace( v_in, UNISTR('\03A7'), 'X'); -- replace greek X, no need for this unless your users type in greek :-)
@christoforosl
christoforosl / UICollectionView+Exts.swift
Created August 4, 2018 07:28 — forked from freak4pc/UICollectionView+Exts.swift
UICollectionView Extension to scroll to confirm validity of IndexPath before scrolling to it
import UIKit
extension UICollectionView {
func isIndexPathAvailable(_ indexPath: IndexPath) -> Bool {
guard dataSource != nil,
indexPath.section < numberOfSections,
indexPath.item < numberOfItems(inSection: indexPath.section) else {
return false
}
@christoforosl
christoforosl / 2017AthensMarathonCalendar
Created July 18, 2017 09:36
Import into your google calendar to create a 20 week countdown to Athens marathon.
BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:ATHENSMARAHON
X-WR-TIMEZONE:Europe/London
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTART;VALUE=DATE:20171112
DTEND;VALUE=DATE:20171112
SUMMARY:Athens Marathon Date
@christoforosl
christoforosl / createWeekCountdownCalendarForAthensMarathon2017.java
Last active July 25, 2018 13:34
Create google calendar for week countdown to Athens marathon
package org.athens.marathon
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
*
* @author christoforosl