Skip to content

Instantly share code, notes, and snippets.

View junibrosas's full-sized avatar
🎯
Create! create! create!

Juni Brosas junibrosas

🎯
Create! create! create!
View GitHub Profile
@junibrosas
junibrosas / .gitlab-ci.yml
Created October 11, 2020 16:28 — forked from thornbill/.gitlab-ci.yml
Example Node GitLab CI Yamlfile
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: node:6
before_script:
- npm install
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
<?php
$random = rand();
$date = date('Y-m-d H:i:s');
$report_to_file = true;
$report_page = "./csp.php?report=1";
$report_file_name = "report.txt";
$intercom_app_id = "YOUR_APP_ID";
/**
* Component that loads script.
* It gives you a callback, so you can continue doing stuff once script get loaded.
*/
export interface mapWrapperProps{
asyncScriptOnLoad?:()=>void;
libraries?:string;
}
@junibrosas
junibrosas / docker-help.md
Created August 4, 2020 04:13 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx}": "eslint --cache --fix"
},
/**
@junibrosas
junibrosas / promise.js
Last active June 3, 2020 06:05
Async Await
let characterResponse = await fetch('http://swapi.co/api/people/2/')
let characterResponseJson = await characterResponse.json()
let films = await Promise.all(
characterResponseJson.films.map(async filmUrl => {
let filmResponse = await fetch(filmUrl)
return filmResponse.json()
})
)
console.log(films)
@junibrosas
junibrosas / moment.js
Last active November 22, 2019 08:21
Anything momentJS
// a few seconds ago
moment.fn.fromNowOrNow = function (a) {
if (Math.abs(moment().diff(this)) < 25000) { // 25 seconds before or after now
return 'just now';
}
return this.fromNow(a);
}
// check expiry
const isExpired = moment().isAfter(activity.endDate);
@junibrosas
junibrosas / .babelrc
Created September 4, 2019 05:30
Transpile async await
{
"presets": [
["@babel/preset-env", {
"modules": false,
"useBuiltIns": "entry",
"targets": {
"browsers": [
"> 0.25%",
"not dead"
],
@junibrosas
junibrosas / lookup.js
Last active July 16, 2019 05:23
MongoDB Aggregation
export const populateUserActions = (userCuid, period = { from: new Date(), to: null }) => {
const aggregation = [
{ $match: { 'cuid': userCuid }},
{ $lookup: CompanyLookup },
{ $lookup: FundraisingLookup },
{ $lookup: MissionLookup },
{ $lookup: CreatedExperienceLookup },
{ $lookup: SubscribedExperienceLookup },
{ $project: {
...simpleUserProjection,