Skip to content

Instantly share code, notes, and snippets.

View rikukissa's full-sized avatar
🍔

Riku Rouvila rikukissa

🍔
View GitHub Profile
@rikukissa
rikukissa / POST.md
Last active July 11, 2025 00:14
React Hook prompting the user to "Add to homescreen" 🏠 #PWA #React
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.

React Hook for showing custom "Add to homescreen" prompt

@rikukissa
rikukissa / LICENCE
Last active November 18, 2018 07:21
Very Cool Uncle Bob SVG
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
@rikukissa
rikukissa / POST.md
Last active July 21, 2019 19:26
On useless try-catches, being overly defensive, I/O boundaries and variable scope #best practices #refactoring #code review
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.

On useless try-catches, being overly defensive, I/O boundaries and variable scope

@rikukissa
rikukissa / POST.md
Last active August 10, 2019 07:40
Define value boundaries early, keep things flat #best practices #refactoring #code review
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.

Why early returns make your code easier to understand

@rikukissa
rikukissa / README.md
Last active September 19, 2019 07:04
Collection of code simplification and refactoring tips #best practices #refactoring #code review

logo


Collection of code simplification and refactoring tips

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.

@rikukissa
rikukissa / PrintDict.vba
Created August 16, 2018 13:08
Dictionary printer for Visual Basic
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
@rikukissa
rikukissa / flow.json
Last active February 11, 2018 14:38
Google face detection for Node-RED
[
{
"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",
@rikukissa
rikukissa / _touchbar.png
Last active December 26, 2017 15:03
Crypto ticker for MacBook Touch Bar
_touchbar.png
@rikukissa
rikukissa / POST.md
Last active July 21, 2019 19:26
Scaling a Redux app - reusable containers #redux
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.

Scaling a Redux app - reusable containers

@rikukissa
rikukissa / widgets.md
Last active August 26, 2017 15:47
Creating isolated Redux widgets