Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Focusing

Dimitri DO BAIRRO rimiti

🚀
Focusing
View GitHub Profile
@rimiti
rimiti / README.md
Created Dec 29, 2018
Benchmark: Template string array stringified VS join() ?
View README.md

Array stringified VS join(), who win ?

Template string (ES6)

function test() {
let array = ["email","groups_access_member_info","publish_to_groups","user_age_range","user_birthday","user_events","user_friends","user_gender","user_hometown","user_likes","user_link","user_location","user_photos","user_posts","user_tagged_places","user_videos"];

return `${array}`;
}
@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 / bg.jpg
Last active Jan 14, 2019
cdn-coming-soon.min.js
@rimiti
rimiti / README.md
Created Jul 27, 2018
Sending JSON object into form data field with request
View README.md

Sending JSON object into form data field with request

How to run it?

npm i request -S
@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;
}
@rimiti
rimiti / main.yml
Created Apr 26, 2018
How to install MySQL 5.7 with Ansible
View main.yml
# Add PGP key to install mysql 5.7 from mysql repository
- name: Add PGP key
apt_key:
keyserver: hkp://pgp.mit.edu:80
id: 5072E1F5
- name: Add official APT repository
apt_repository:
repo: "deb http://repo.mysql.com/apt/debian/ stretch mysql-5.7"
@rimiti
rimiti / index.js
Created Apr 5, 2018
Node: Await without catching ? It's really bad...
View index.js
const Test = (ms) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
if(ms === 20) reject(new Error('Bad value'));
resolve('ok');
}, ms);
});
}
async function testUnhandled() {
@rimiti
rimiti / Listing.md
Last active Jan 31, 2018
Git - Best commands list
View Listing.md
  • Remove all local branches (except master)
git branch | grep -v "master" | xargs git branch -D
View gist:ed3261d377aae84924f1125e04071a1b
[!] 34 vulnerabilities identified from the version number
[!] Title: WordPress 4.2-4.5.1 - MediaElement.js Reflected Cross-Site Scripting (XSS)
Reference: https://wpvulndb.com/vulnerabilities/8488
Reference: https://wordpress.org/news/2016/05/wordpress-4-5-2/
Reference: https://github.com/WordPress/WordPress/commit/a493dc0ab5819c8b831173185f1334b7c3e02e36
Reference: https://gist.github.com/cure53/df34ea68c26441f3ae98f821ba1feb9c
Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-4567
[i] Fixed in: 4.5.2
You can’t perform that action at this time.