Skip to content

Instantly share code, notes, and snippets.

View tomaszczechowski's full-sized avatar
🚀
Working remotely

Tomasz Czechowski tomaszczechowski

🚀
Working remotely
View GitHub Profile
@tomaszczechowski
tomaszczechowski / 00_README.md
Created October 21, 2022 11:36 — forked from LeZuse/00_README.md
Install node on Apple Silicon M1 both ARM and x86 (Rosetta)

Node.js on Apple Silicon

Node Version Manager (https://github.com/nvm-sh/nvm) works perfectly across native node installations as well as emulated Rosetta installations. The trick I am using here is to install one LTS version of node under Rosetta and another stable version as native binary.

TODO

  • find a way how to run the same node version on both platforms
@tomaszczechowski
tomaszczechowski / aws_secrect_manager.js
Last active April 13, 2021 14:21
AWS Secrect Manager
const AWS = require('aws-sdk');
const secretsManager = new AWS.SecretsManager();
const types = {
"rds": `{env}/rds`
};
const getSecret = async (type, env = process.env.ENV) => {
const SecretId = types[type].replace('{env}', env);
const secret = await secretsManager.getSecretValue({ SecretId }).promise();
@tomaszczechowski
tomaszczechowski / date.tsx
Created October 24, 2018 06:05
Date compontent
import * as React from 'react';
import { connect } from 'react-redux';
import { IState } from '../reducers/root.reducer';
import { IUserGeneral } from '../reducers/user.reducer';
import moment from 'moment-timezone';
import { Moment } from 'moment';
interface IComponentProps {
userDateTimeSettings: IUserGeneral;
date: string;
@tomaszczechowski
tomaszczechowski / sync.class.ts
Created October 24, 2018 05:49
Class used to sync data between localstorage and backend
import { ITask } from '../reducers/tasks.reducer';
import { API } from 'aws-amplify';
const SYNC_LOCAL_STORAGE_PREFIX = 'app-name-here';
const SYNC_INTERVAL = 5000;
export default class Sync {
private static syncListeners: {
'tasks'?: (tasks: ITask[]) => {},
'action:isSyncing'?: (isSyncing: boolean) => {},
@tomaszczechowski
tomaszczechowski / format.js
Last active April 4, 2019 06:16
Format dates according to location
// written within 30 second, just to check if works and it works ;-)
// probably needs to be improved afterwards.
const getLocalFormat = () => {
// need to set day of month higher than 12 to not confuse it with month value during matching.
const date = moment().year(2018).month(6).date(30).toDate().toLocaleDateString().split('/');
const format = [];
date.map(match => {
if (match === '30') {
format.push('DD');
@tomaszczechowski
tomaszczechowski / flatten.js
Last active December 31, 2018 15:20
JavaScript flatten function
/**
* Method flattens an array of arbitrarily nested arrays of integers into a flat array of integers.
*
* @param {Object} collection - Collection of nested collection's.
* @returns {Object} - flat array of integers.
*/
const flatten = (collection) => {
let response = [];
for (let i = 0; i < collection.length; i++) {