Prompts for auditing code quality and test health. Copy the prompt, paste it after a PR / at end of week / monthly.
This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.
I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)
Before trying it out DIY, I considered using:
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
| " UI | |
| syntax on | |
| highlight Normal ctermbg=None | |
| set guifont=OperatorMono-Book:h16 | |
| " Fix cursor display in cygwin | |
| if has("win32unix") | |
| let &t_ti.="\e[1 q" | |
| let &t_SI.="\e[5 q" | |
| let &t_EI.="\e[1 q" |
In your command-line run the following commands:
brew doctorbrew update
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 App extends React.Component { | |
| state = { showError: true } | |
| toggleError = () => { | |
| this.setState((prevState, props) => { | |
| return { showError: !prevState.showError } | |
| }) | |
| }; | |
| render() { |
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 DivWithErrorHandling = withErrorHandling(({children}) => <div>{children}</div>) |
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 withErrorHandling = WrappedComponent => ({ showError, children }) => { | |
| return ( | |
| <WrappedComponent> | |
| {showError && <div className="error-message">Oops! Something went wrong!</div>} | |
| {children} | |
| </WrappedComponent> | |
| ); | |
| }; |
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
| render () { | |
| return ( | |
| <div> | |
| {this.props.errors && <div>Error Message</div>} | |
| <h1>Your Amazing Content</h1> | |
| </div> | |
| ); | |
| } |
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
| /* | |
| 0 - Sunday | |
| 1 - Monday | |
| 2 - Tuesday | |
| 3 - Wednesday | |
| 4 - Thursday | |
| 5 - Friday | |
| 6 - Saturday |
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
| <script type="text/javascript"> | |
| window.onload=function() { | |
| var el = document.getElementById('postComment').addEventListener('click', registerClickHandler); | |
| function registerClickHandler() { | |
| var inputValue = document.getElementById('comment').value; | |
| var list = document.getElementById('commentList'); | |
| if (inputValue) { | |
| var listNode = document.createElement("LI"); |
NewerOlder