- App features:
- public blog posts pages (anyone can see)
- login / logout
- create / update / delete for user's own posts
- signed-in user can view their posts (include draft posts)
- Unit tests
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
# frozen_string_literal: true | |
# Use Active Record Encryption for newer version of Rails | |
# https://edgeguides.rubyonrails.org/active_record_encryption.html | |
module ReversibleEncryptedAttribute | |
extend ActiveSupport::Concern | |
COLUMN_PREFIX = "encrypted" | |
class_methods do |
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
// Original Article: https://thesmartcoder.dev/awesome-react-hooks/ | |
// | |
// I just wrote hooks that I'm interested in. | |
import { useRef, useEffect, useState } from "react"; | |
function useTimeout(callback: Callback, delay: number) { | |
const savedCallback = useRef<Callback>(); | |
useEffect(() => { |
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
function fileToBase64(file: File): Promise<string | ArrayBuffer | null> { | |
return new Promise((resolve, reject) => { | |
const r = new FileReader() | |
r.onload = () => resolve(r.result) | |
r.onerror = (err) => reject(err) | |
r.readAsDataURL(file) | |
}) | |
} | |
async function base64ToFile(str: string, fileName: string = "newfile.txt", type: string = "text/plain"): Promise<File> { |
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
/** | |
* @see https://react-redux.js.org/api/hooks | |
* | |
* This code is just a sample code for learning | |
* and several expected features are lacked. | |
*/ | |
import { ChangeEvent, KeyboardEvent } from "react"; | |
import { createStore, Reducer } from "redux"; | |
import { Provider, useDispatch, useSelector } from "react-redux"; |
- This is not religious or philosophy, but art and practice.
- Pursuit rationality and mental health.
- You can apply this to both company projects and your own private project because who u r today is different from who is yesterday.
- Simple and clear, the 1st line is a summary of the commit:
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 SECONDS = 1000; | |
const MINUTES = SECONDS * 60; | |
const HOURS = MINUTES * 60; | |
interface Result { | |
hours: number; | |
minutes: number; | |
seconds: number; | |
} |
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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile do | |
source "https://rubygems.org" | |
gem "virtus" | |
end |
- Using GitHub, GitLab or similar de facto git hosting/collaborating services
- Many public chat messages, a few private ones
- Preferring remote/asynchronous communication to synchronous one
- Well-tested and -documented applications
- No routine meetings: discuss whenever necessary
- Higher priority for code review with respecting team mates' motivation
- Make code/projects public as mush as possible rather than trying hard to write "tech blog"
- CI/CD
- linter/formatter: not discuss code styles or preferences during code review
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 Test | |
extend Gem::Deprecate | |
# DEPRECATED | |
def foo | |
puts "foo" | |
end | |
def bar | |
puts "bar" |