Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Focusing

Dimitri DO BAIRRO rimiti

🚀
Focusing
View GitHub Profile
@rimiti
rimiti / ipstack.ts
Last active Jul 31, 2020
Typescript implementation of ipstack
View ipstack.ts
import axios, { AxiosResponse } from 'axios';
import { config } from '../config';
import { Sentry } from '../libs/sentry';
/**
* @description Ip Stack API response
*/
interface IIpStackResponse {
latitude: number;
longitude: number;
@rimiti
rimiti / example.js
Created Oct 1, 2019
Javascript: Creating a custom javascript error
View example.js
export class RequestError extends Error {
constructor(message, meta = {}) {
super();
this.message = message;
this.meta = meta;
}
}
@rimiti
rimiti / sentry.js
Created Oct 1, 2019
Example to capture a Sentry exception
View sentry.js
const Sentry = require('@sentry/node');
Sentry.init({ dsn: process.env.SENTRY_DSN, environment: 'staging' });
Sentry.captureException(new Error('Test from local'));
@rimiti
rimiti / 🙈❤️.png
Last active Oct 25, 2019
Raccoon﹠Monkey lover ❤️
@rimiti
rimiti / index.js
Created Apr 23, 2019
Loop: running promises in sequential.
View index.js
/**
* @description Runs getUser() in sequential.
* @return {Promise<void>}
*/
async function example() {
for (let i = 0; i < 10; i++) {
await getUser();
}
}
@hadrienblanc
hadrienblanc / git-submodules.md
Last active Jan 10, 2019
Git submodules cheatsheet
View git-submodules.md

Git Submodules cheatsheet

Why having a submodule ?

With git you can add a submodule to a repository. A submodule is another repository inside a repository.

How to create a submodule ?

git submodule add git@github.com:my_account/my_submodule.git path_to_my_submodule
@npearce
npearce / install-docker.md
Last active Aug 7, 2020
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command
View install-docker.md

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@rimiti
rimiti / upload-to-s3-steam.js
Created Nov 20, 2018
NodeJS - Upload local (file) image to AWS S3 from stream with public access.
View upload-to-s3-steam.js
const AWS = require('aws-sdk');
const fs = require('fs');
AWS.config.update({ accessKeyId: 'ACCESSKEYID', secretAccessKey: 'SECRETACCESSKEY', region: 'eu-west-3'});
const fileStream = fs.createReadStream('/path/to/your/image.png');
fileStream.on('error', function (err) {
if (err) { throw err; }
});
@rimiti
rimiti / installations.sh
Last active Jul 5, 2018
Install kubernetes on Debian 9 (online.net)
View installations.sh
#!/bin/sh
# Install common and docker
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable"
apt-get update && apt-get install -y docker-ce=$(apt-cache madison docker-ce | grep 17.03 | head -1 | awk '{print $3}')
# Install kubelet, kubeadm kubectl
@rimiti
rimiti / index.js
Created Jun 9, 2018
Retrieving routeName from react-navigation state (redux implementation)
View index.js
/**
* @description Returns current route name.
* @param routes
* @returns {string}
*/
getRouteNameFromNavigatorState ({ routes }) {
let route = routes[routes.length - 1];
while (route.index !== undefined) route = route.routes[route.index];
return route.routeName;
}
You can’t perform that action at this time.