Skip to content

Instantly share code, notes, and snippets.

View raulingg's full-sized avatar
🛠️
Fixing bugs

Raul Quispe raulingg

🛠️
Fixing bugs
View GitHub Profile
@raulingg
raulingg / reduce-promises.js
Created November 22, 2019 17:25
resolve promise sequentially by reduce
[...cohortSlugs].reduce((prevPromise, slug) => {
let applications;
return prevPromise
.then((acc) => {
applications = acc;
return Cohort.findOne({ slug });
})
.then(({ _id: cohort }) => [
...applications,
...applicationsFromFirestore
@raulingg
raulingg / local-mongo-replicaset-with-docker
Last active November 18, 2019 22:50 — forked from oleurud/local-mongo-replicaset-with-docker
[Local mongo replicaset with docker] #docker #mongo
# pull the official mongo docker container
docker pull mongo
# create network
docker network create mongo-cluster
# create mongos
docker run -d --net mongo-cluster -p 27017:27017 --name mongo-primary mongo mongod --replSet mongo-set --port 27017
docker run -d --net mongo-cluster -p 27018:27018 --name mongo-secondary mongo mongod --replSet mongo-set --port 27018
@raulingg
raulingg / SortingByLocaleCompare.js
Last active September 18, 2019 15:48
Comparing common sorting and String.localeCompare to sort alphabetically
const people = [
{
name: 'Ráulingg Robin alphabetically',
age: 30
},
{
name: 'rolandó'
},
{
name: 'Rolandó'
@raulingg
raulingg / moneyFormatHelper.js
Created October 3, 2018 19:01
Handle money in javascript
var formatDollarsToCents = function(value) {
value = (value + '').replace(/[^\d.-]/g, '');
if (value && value.includes('.')) {
value = value.substring(0, value.indexOf('.') + 3);
}
return !isNaN(value) ? Math.round(parseFloat(value) * 100) : 0;
}
var formatCentsToDollars = function(value) {
@raulingg
raulingg / database.rules.json
Created October 2, 2018 20:38 — forked from codediodeio/database.rules.json
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
select
id, name
from
courses
where
name like "%Gabriel%"
or (JSON_EXTRACT(lessons, "$[*].name") like "%Gabriel%")
or (JSON_EXTRACT(lessons, "$[*].subjects[*].name") like "%Gabriel%");
@setup
if (! in_array($env, ['staging', 'production'])) {
throw new Exception('--env must be "staging" or "production"');
}
$uppecaserEnv = strtoupper($env);
try {
require __DIR__ . '/vendor/autoload.php';
@raulingg
raulingg / .hyper.js
Last active May 12, 2018 01:50
to sync hyper term settings
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@raulingg
raulingg / cloudSettings
Last active September 18, 2021 15:44
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-09-18T15:44:04.716Z","extensionVersion":"v3.4.3"}