Skip to content

Instantly share code, notes, and snippets.

View MorenoMdz's full-sized avatar
🎯
Focusing

MorenoMdz

🎯
Focusing
  • Self
  • Florianópolis
View GitHub Profile
@MorenoMdz
MorenoMdz / max 25char javascript
Created July 22, 2018 02:19
ES6 Limit to 25 char display.
p= store.description.split(' ').slice(0, 25).join(' ')
@MorenoMdz
MorenoMdz / gist:f8f30ef941680e94647b99e86e764925
Created August 5, 2018 18:13
HackerRank day 1 Data Types
// Declare second integer, double, and String variables.
let secondInteger, secondDouble, secondString
// Read and save an integer, double, and String to your variables.
/* Using readline and parsing the input into the variables declared previously */
secondInteger = parseInt(readLine());
secondDouble = parseFloat(readLine());
secondString = readLine();
@MorenoMdz
MorenoMdz / aws.js
Created September 6, 2018 02:41
Image upload, resize and rename with AWS S3 with node and Multer S3
const multer = require('multer');
const multerS3 = require('multer-s3');
const uuid = require('uuid');
const AWS = require('aws-sdk');
const sharp = require('sharp');
AWS.config.update({
accessKeyId: process.env.AWS_ACCESS,
secretAccessKey: process.env.AWS_SECRET_KEY
});
@MorenoMdz
MorenoMdz / all
Created September 6, 2018 20:30
Git versioning
Start my project at 1.0.0 in package.json
Initial dev work
Push to develop branch
Push to master branch
Tag as v1.0.0
Dev
Push to 'feature/name-of-feature' or 'bug/name-of-bug' branches
Merge pull request of feature and bug branches into develop
When it's ready for release, determine the version number (1.0.1 or 1.1.0) and update package.json
Push package.json to develop branch
@MorenoMdz
MorenoMdz / validateEmails.js
Created September 20, 2018 02:35
Email validation util.
// It splits by comma then map and trim each emai, then check each email pass the test, keeping the ones that do not pass the test.
// If any email do not pass the regex test show it to the user, otherwise continue (return)
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
export default emails => {
const invalidEmails = emails
.split(',')
.map(email => email.trim())
.filter(email => re.test(email) === false);
@MorenoMdz
MorenoMdz / es2018.js
Created October 19, 2018 18:07
ES2018 Examples
// Spread to remove field
const user = {
firstName: 'John',
lastName: 'Doe',
city: 'Here'
}
const { city, ...userWIthoutCity} = user
city // here
userWIthoutCity // {firstName: 'John', lastName: 'Doe'}
@MorenoMdz
MorenoMdz / filterVirtual.js
Created November 19, 2018 00:30
Mongoose JS filter a virtual field by its length
exports.getNewProblemsList = async (req, res, next) => {
const page = req.params.page || 1;
const limit = 10;
const skip = page * limit - limit;
const problemPromise = Problem.find()
.populate('author hardware repairsV', 'name')
.skip(skip)
.limit(limit)
.sort({ created: 1 })
@MorenoMdz
MorenoMdz / linux-commands.md
Created March 16, 2019 21:02
A bunch of usefull linux commands

Linux Mint set display gamma xrandr --output eDP-1 --gamma 0.86:0.86:0.86

@MorenoMdz
MorenoMdz / rn_new-app_setup.md
Last active September 3, 2019 02:28
React Native boilerplate
```
for each (unsorted) partition
set first element as pivot
storeIndex = pivotIndex + 1
for i = pivotIndex + 1 to rightmostIndex
if element[i] < element[pivot]