Skip to content

Instantly share code, notes, and snippets.

@codinronan
codinronan / events.service.ts
Last active June 9, 2018 00:20
Decorator for Ionic Storage
import { Injectable, NgZone } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { ReplaySubject } from 'rxjs/ReplaySubject';
// We use a ReplaySubject instead of a Subject or BehaviorSubject because we want to ensure 2 things:
// 1. That new subscribers receive any current values
// 2. That if the subject has never been invoked, no value is passed when a subscriber is wired up.
// Subject does not provide replay behavior (providing the current value), and BehaviorSubject
// requires an initial value, which may not be appropriate to the event.
// Therefore ReplaySubject, with a 1-element window, is the correct choice.
@codinronan
codinronan / bp.txt
Created January 17, 2019 08:02
React best practices
https://www.reddit.com/r/reactjs/comments/agpo04/react_best_practices/
@codinronan
codinronan / PluginLinks.txt
Last active February 12, 2019 05:27
Cordova
@codinronan
codinronan / hooks.txt
Last active February 12, 2019 05:45
React Hooks
https://usehooks.com/useDarkMode/
--> https://github.com/donavon/use-dark-mode
https://usehooks.com/useLocalStorage/
https://usehooks.com/useMedia/
https://github.com/donavon/use-persisted-state
https://github.com/gragland/usehooks/tree/master/src/pages
https://www.reddit.com/r/reactjs/comments/apf7bz/rreactjs_hooks_contest_winners/
@codinronan
codinronan / components.txt
Last active February 12, 2019 05:53
React components
https://github.com/tajo/react-range - only 3.2kb minzipped, smallest I've ever seen, fully stylable and fully accessible
https://github.com/tajo/react-movable - better than draggable or dragula or dropzone, all of which are huge - this is only 3.8kb minzipped
@codinronan
codinronan / custom-error.js
Created April 21, 2019 04:39 — forked from justmoon/custom-error.js
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@codinronan
codinronan / some.component.html
Created May 13, 2019 06:11 — forked from ValentinFunk/some.component.html
Angular 2 Waypoints using ng2-scrollspy
<div scrollSpy>
<div [waypoint]="i" *ngFor="let i of [1,2,3,4,5,6,7,8]">
{{ i }}
</div>
</div>
.rounded-corners-gradient-borders {
width: 300px;
height: 80px;
border: double 4px transparent;
border-radius: 80px;
background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff);
background-origin: border-box;
background-clip: content-box, border-box;
}
@codinronan
codinronan / useDimensions.js
Created July 18, 2019 03:22 — forked from EduVencovsky/useDimensions.js
React Native Hook for Dimensions
import { useState, useEffect } from 'react'
import { Dimensions } from 'react-native'
const useDimensions = getter => {
const [dimensions, setDimensions] = useState(Dimensions.get(getter))
useEffect(() => {
const widthHandler = d => setDimensions(d[getter])
Dimensions.addEventListener('change', widthHandler)
return () => Dimensions.removeEventListener('change', widthHandler)
})
@codinronan
codinronan / 01_install_yarn.config
Created February 9, 2020 23:33 — forked from cooperka/01_install_yarn.config
AWS Elastic Beanstalk - Replace npm with yarn
# .ebextensions/01_install_yarn.config
files:
'/opt/elasticbeanstalk/hooks/appdeploy/pre/49install_yarn.sh' :
mode: '000755'
owner: root
group: root
content: |
#!/usr/bin/env bash
set -euxo pipefail