This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const deepEqual = (object1, object2) =>{ | |
const keys1 = Object.keys(object1); | |
const keys2 = Object.keys(object2); | |
if (keys1.length !== keys2.length) { | |
return false; | |
} | |
for (const key of keys1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef, useReducer } from 'react'; | |
export const useFetch = (url) => { | |
const cache = useRef({}); | |
const initialState = { | |
status: 'idle', | |
error: null, | |
data: [], | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEmpty = (el) => { | |
switch (typeof value) { | |
case 'array': | |
return el.length === 0; | |
case 'object': | |
return "object.values(el).length === 0"; | |
default: | |
return false; | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ErrorSerializer | |
attr_accessor :request, :params, :errors | |
def initialize(request, params, errors = [], exception = nil) | |
@request = request | |
@params = params | |
@errors = errors | |
@exception = exception | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
IonPage, | |
IonAvatar, | |
IonList, | |
IonLabel, | |
IonItem, | |
IonIcon, | |
IonHeader, | |
IonToolbar, | |
IonTitle, |
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: