Skip to content

Instantly share code, notes, and snippets.

@pettomartino
pettomartino / script.conf
Created May 22, 2018
execute a command on start up ubuntu
View script.conf
# save it on /etc/init
start on startup
task
exec /path/to/command
@pettomartino
pettomartino / retry.js
Last active Mar 12, 2019
Retry promise
View retry.js
const retry = (fn, options = {}) => new Promise((resolve, reject) => {
const { retryInterval = 500, retries = 1 } = options;
fn()
.then(resolve)
.catch(err => (
(retries === 0)
? reject(err)
: setTimeout(
() => retry(fn, { retryInterval, retries: retries - 1 }).then(resolve, reject),
retryInterval,
@pettomartino
pettomartino / view.controller.tsx
Created Dec 16, 2019
Authenticate controller
View view.controller.tsx
import { Context, dependency, Get, render, TokenRequired } from '@foal/core';
import * as React from 'react';
import * as ReactDOMServer from 'react-dom/server';
import { User } from '../entities';
import { TypeORMStore } from '@foal/typeorm';
export class ViewController {
@dependency
store: TypeORMStore;
@pettomartino
pettomartino / styledExtended.tsx
Last active Aug 9, 2020
Use styled components with LinearGradient and pass props
View styledExtended.tsx
const Background = styled(LinearGradient).attrs(() => ({
colors: ['#464769', '#1B1A1F'],
}))`
padding-top: 50px;
flex: 1;
`