Skip to content

Instantly share code, notes, and snippets.

View RomanTurner's full-sized avatar
🤫

Roman RomanTurner

🤫
View GitHub Profile
@RomanTurner
RomanTurner / clean_code.md
Created July 6, 2022 16:43 — 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

@RomanTurner
RomanTurner / railsconf_2022.md
Created May 7, 2022 21:55
RailsConf 2022 Schedule

Rails Conference Schedule

TUESDAY

Leveling up. From Planning to Production

By: Tomas Countz Room: Portland BR 254

  • 10:40am-11:10am Leveling up. From Planning to Production BR 254

Rails C With Me: The Interactive Console as a Superpower

Keybase proof

I hereby claim:

  • I am romanturner on github.
  • I am roman_turner (https://keybase.io/roman_turner) on keybase.
  • I have a public key ASB_UPBaO_9FjC3tuy7Uch3-FihmN4GeaWKxUs3IxD_7UAo

To claim this, I am signing this object:

@RomanTurner
RomanTurner / schedule.tsx
Created March 29, 2022 23:52
Schedule Component for Ionic Mobile Application
import {
IonPage,
IonAvatar,
IonList,
IonLabel,
IonItem,
IonIcon,
IonHeader,
IonToolbar,
IonTitle,
@RomanTurner
RomanTurner / error_serializer.rb
Created March 14, 2022 21:50
Error Class for JSON API can be extended to serialize different execptional creatures.
class ErrorSerializer
attr_accessor :request, :params, :errors
def initialize(request, params, errors = [], exception = nil)
@request = request
@params = params
@errors = errors
@exception = exception
end
@RomanTurner
RomanTurner / filtering_and_sorting.js
Last active March 17, 2022 19:19
Composes Sorting and Filtering on user input.
// Generate Test Data
const randomDate = (start, end) => {
return new Date(
start.getTime() + Math.random() * (end.getTime() - start.getTime()),
);
};
const randomString = (length) => {
let result = '';
const characters =
@RomanTurner
RomanTurner / nop.js
Last active February 16, 2022 19:55
Null Object Pattern with React custom hooks
const isEmpty = (el) => {
switch (typeof value) {
case 'array':
return el.length === 0;
case 'object':
return "object.values(el).length === 0";
default:
return false;
};
};
@RomanTurner
RomanTurner / useFetch.js
Created September 23, 2021 17:26
React Custom Hook for GET request w/ Caching
import { useEffect, useRef, useReducer } from 'react';
export const useFetch = (url) => {
const cache = useRef({});
const initialState = {
status: 'idle',
error: null,
data: [],
};
@RomanTurner
RomanTurner / create_table_types.rb
Created September 10, 2021 21:05
A list of types you can use in the Rails migration dsl
def change
create_table :table do |t|
t.column # adds an ordinary column. Ex: t.column(:name, :string)
t.index # adds a new index.
t.timestamps
t.change # changes the column definition. Ex: t.change(:name, :string, :limit => 80)
t.change_default # changes the column default value.
t.rename # changes the name of the column.
t.references
t.belongs_to #alias for references
const STORIES_URL = 'https://hacker-news.firebaseio.com/v0/topstories.json';
const ITEMS_URL = 'https://hacker-news.firebaseio.com/v0/item/';
const getStoryIds = async () => {
const response = await fetch(STORIES_URL);
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
const result = await response.json();