| title | slug | createdAt | language | preview |
|---|---|---|---|---|
React Hook prompting the user to "Add to homescreen" |
react-hook-prompting-the-user-to-add |
2018-11-29T20:35:02Z |
en |
Simple React Hook for showing the user a custom "Add to homescreen" prompt. |
| MIT License | |
| Copyright (c) 2018 Riku Rouvila | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE O |
| title | slug | createdAt | language | preview |
|---|---|---|---|---|
On useless try-catches, being overly defensive, I/O boundaries and variable scope |
on-useless-try-catches-being-overly-defensive |
2018-11-03T10:43:09Z |
en |
Many things can go wrong when try-catch is used, especially in an asynchronous context. As a structure try-catch is quite powerful and should be used sparingly, only when it's really needed. |
| title | slug | createdAt | language | preview |
|---|---|---|---|---|
Define value boundaries early, keep things flat |
define-value-boundaries-early-keep-things-flat |
2018-11-01T18:45:46Z |
en |
This is actually one of my personal favourite refactors. It reduces nesting, gives structure for functions and in many cases provides the answer to readers' question quicker. |
Want to write clean code? Well here's your chance. The following set of examples are practices that I've come across during my times as a programmer and that I believe in. At least at the moment. Please feel free to add comments, criticise my thinking and contribute to everyone's knowledge. I'm trying to find a better platform for these, but for now a gist should do. I'm doing this solely to document, analyse and share my own thinking, which oftentimes is quite unstructured. These days I'm not too fussed about the syntactical structures of the code, but would rather concentrate on painting the largest guidelines and deciding the direction I want my programming style to move towards.
| Function PrintDict(Dict as Dictionary, Optional ByVal Stack as String = "") | |
| For Each Key In Dict.Keys() | |
| If TypeOf Dict(Key) Is Dictionary Then | |
| Debug.Print Stack & Key & ":" | |
| PrintDict Dict(Key), Stack & " " | |
| Else | |
| Debug.Print Stack & Key & ": " & Dict(Key) | |
| End If | |
| Next | |
| End Function |
| [ | |
| { | |
| "id": "d6e8fa47.38bfd8", | |
| "type": "http request", | |
| "z": "a2a19eb0.8be53", | |
| "name": "Google Vision", | |
| "method": "POST", | |
| "ret": "obj", | |
| "url": | |
| "https://vision.googleapis.com/v1/images:annotate?key=AIAIAIAIAIAIAXYXYXYXYXYXYXYXYXY", |
| title | slug | createdAt | language | preview |
|---|---|---|---|---|
Scaling a Redux app - reusable containers |
scaling-a-redux-app-reusable-containers-redux |
2017-11-12T14:11:50Z |
en |
The idea here is to experiment with building Redux applications by reusing Redux applications. So basically a classic Yo Dawg situation. I'm doing this in the name of science and in the hope that future generations would have a more structured way of building user interfaces. |
https://github.com/rikukissa/redux-isolated-apps
http://redux.js.org/docs/recipes/IsolatingSubapps.html
Pros:
- Minimalistic approach, easy to understand
- Minimal code changes required when isolating pieces of UI
- Easy integration with redux-loop, redux-forms etc
